Repository navigation
assertpy 2.35.0 is the typed rewrite published until now as assertpy2, released under the original name: the first assertpy release since 1.1 in 2020
A major release. On 1.1 your imports stay the same, but some results, extensions and messages change
Thanks to Justin Shacklette for handing over the name, and to everyone who contributed to 1.x
TL;DR
| You use | What to do |
|---|---|
assertpy 1.1, upgrading |
Read Upgrading from assertpy 1.x, remove types-assertpy, run your tests |
assertpy 1.1, staying |
Pin assertpy<2. The 1.x source is on the v1.x branch |
assertpy2 |
Switch the dependency and imports to assertpy. assertpy2 2.35.0 keeps old imports working meanwhile |
Coming from assertpy 1.1
The same assert_that(...) chain, plus:
- type safety: the checker offers only the assertions that fit the value
- structured failures with a path-level diff
- matchers, in assertions and inside plain
== - thread- and async-safe soft assertions, polling, snapshots
A major release, so some things change:
assert_that(float("nan")).is_greater_than(1)Before (1.1)
passed
Now
AssertionFailure: Expected <nan> to be greater than <1>, but was not.
- Some results change, in either direction: NaN in comparisons,
boolinis_close_to(), and more add_extension()refuses a taken name withoutoverride=True- Failures raise
AssertionFailure, a subclass ofAssertionError - Many messages are reworded: tests matching message text may need updating
- Python 3.10+. Older interpreters keep getting 1.1
- When upgrading, remove
types-assertpy: it describes 1.1 and hides the 2.x types
Guide: Upgrading from assertpy 1.x
Coming from assertpy2
- assertpy2[json]
+ assertpy[json]- from assertpy2 import assert_that
+ from assertpy import assert_thatOld flags, settings and environment variables still work, with a warning:
$ pytest --assertpy2-snapshot-update
FutureWarning: --assertpy2-snapshot-update is the assertpy2 name of --assertpy-snapshot-update. It keeps working until assertpy 3.0, use --assertpy-snapshot-update instead.
- New names drop the
2:--assertpy-snapshot-update,assertpy_diff,ASSERTPY_SNAPSHOT_CI. Old ones go in 3.0 - Under warnings-as-errors the warning stops the run: rename, or filter
ignore:.*is the assertpy2 name of:FutureWarning # assertpy2: allow-danglingis still read- No synonym for the loggers and the plugin name: update them by the table below
Guide: Coming from assertpy2
Behaviour changes
assertpy2 |
assertpy |
|
|---|---|---|
assert_warn() default logger |
assertpy2 |
assertpy |
log_passes() logger |
assertpy2.passes |
assertpy.passes |
| pytest plugin name | -p no:assertpy2 |
-p no:assertpy |