When comparing assertpy vs Verify, the Slant community recommends assertpy for most people. In the question“What are the best assertion libraries for Python? ” assertpy is ranked 2nd while Verify is ranked 3rd. The most important reason people chose assertpy is:
There is only one function to import to use assertpy: `assert_that()`. Assertions are made by passing values as function parameters to the appropriate function(s), e.g. `assert_that('hello').is_equal_to('hello')`.
Ranked in these QuestionsQuestion Ranking
Pros
Pro API is straightforward
There is only one function to import to use assertpy: assert_that()
. Assertions are made by passing values as function parameters to the appropriate function(s), e.g. assert_that('hello').is_equal_to('hello')
.
Pro Compact and Pythonic
Assertions are made through simple Python function calls with idiomatic names.
Pro Supports asserting values beyond normal data types
assertpy has support for asserting values such as datetimes (e.g. assert_that(x).has_year(1980)
), files (e.g. assert_that('foo.txt').exists()
), and objects.
Pro Multiple syntax styles available
verify comes with various syntax styles for the developer to choose from (e.g. ensure(something).is()
, expect(something).to_be()
).