Here’s the Deal
Slant is powered by a community that helps you make informed decisions. Tell us what you’re passionate about to get your personalized feed and help others.
Unlike other assertion libraries, grappa’s syntax is extremely verbose and expressive. It utilises English-like expressions and uses the OR operator (|) for assertion. The assertion methods begin with either should or expect. This makes grappa highly readable and easy to understand, even for non-developers. Examples: to assert that a boolean is true: True | should.be.true, and to assert that a value is within a range: 3.14 | should.be.within(2, 4). See More
Some consider grappa to be too verbose with unnecessary syntactic sugar. Compared to other assertion libraries, grappa is the most expressive of them all, which makes it a double-edged sword: the expressiveness makes it easy to read and understand, but each expression is longer to type and can seem redundant — the same assertion can be done with less code without grappa. See More
For complex assertions with multiple expressions, grappa allows you to chain them together with the > operator. For example, to assert that “hello” should be a string and should be equal to “hello”, we can do: 'hello' | should.be.a(str) > should.be.equal.to('hello'). See More
When an assertion fails in grappa, it outputs a detailed error report. The report contains the reason the assertion failed, the expected and received value(s) in plain English, e.g. "What we expected: an object that can be length measured and its length is equal to 4". It also contains the function grappa used to test the assertion (e.g. len(), for our previous example error message) and provides additional information about the function, along with a link to the Python docs. See More
Help millions of people make better decisions.
Each month, over 2.8 million people use Slant to find the best products and share their knowledge. Pick the tags you’re passionate about to get a personalized feed and begin contributing your knowledge.