You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In recent pytest versions 5.x+ the ways asserts failures are reported changed (rather dramatically if I may say) where the order is now:
assert result == expected
before and that was our org-wide convention we use the reverse:
assert expected == result
This impacts significantly the way we look at test failures traces: the diffs are now unreadable and you need to make the mental switch that plus means minus and minus means plus to make sense of a failure trace.
I always thought that it is more natural to write assertion in this new way e.g. assert result == expected but that was never the convention in unittest, and pytest and related.
To recover sanity and assert again safely that plus == plus and minus=minus I suggest we adopt the way:
define a new org-wide standard to use ths way
progressively update ALL our many tests to use assert result == expected
As an example of the current problem here, this snippet is a failure trace where we expected an mit license_expression to be detected but instead an unknown license_expression was returned:
E "homepage_url": null,
E "keywords": [],
E - "license_expression": "unknown",
E ? ^^^^^^^
E + "license_expression": "mit",
E ? ^^^
E "md5": null,
E "name": "laravel",
E "namespace": "laravel",
Yet, the way this looks is that an unknown license was not detected and an mit was returned instead.
Before we bump to use pytest 5.x the same failure was looking this way:
E "homepage_url": null,
E "keywords": [],
E - "license_expression": "mit",
E ? ^^^
E + "license_expression": "unknown",
E ? ^^^^^^^
E "md5": null,
E "name": "laravel",
E "namespace": "laravel",
and this i how we want things to look again hence the push to reorder all our test assertions
The text was updated successfully, but these errors were encountered:
See
pytest-dev/pytest#3333
https://github.com/pytest-dev/pytest/pull/6673/files
In recent pytest versions 5.x+ the ways asserts failures are reported changed (rather dramatically if I may say) where the order is now:
assert result == expected
before and that was our org-wide convention we use the reverse:
assert expected == result
This impacts significantly the way we look at test failures traces: the diffs are now unreadable and you need to make the mental switch that plus means minus and minus means plus to make sense of a failure trace.
I always thought that it is more natural to write assertion in this new way e.g.
assert result == expected
but that was never the convention in unittest, and pytest and related.To recover sanity and assert again safely that
plus == plus
andminus=minus
I suggest we adopt the way:assert result == expected
As an example of the current problem here, this snippet is a failure trace where we expected an
mit
license_expression to be detected but instead anunknown
license_expression was returned:Yet, the way this looks is that an
unknown
license was not detected and anmit
was returned instead.Before we bump to use pytest 5.x the same failure was looking this way:
and this i how we want things to look again hence the push to reorder all our test assertions
The text was updated successfully, but these errors were encountered: