We currently have two occasions where we need to support backward incompatible changes in test frameworks:
Behave 1.2.7 (a pre-release, as for now) replaced Configuration.tags with Configuration.tag_expression.
pytest 8.1 requires a node object to be passed to FixtureManager.getfixturedefs instead of the nodeid string.
We initially handled those by directly comparing Behave/pytest versions with packaging.version.parse.
The solution works fine in allure-pytest since the packaging module is a transitive dependency of pytest.
On the other hand, allure-behave crashes with ModuleNotFoundError unless packaging becomes available either by hand or via some other package (e.g., setuptools). That happens because packaging is missing in the install_requires metadata of allure-behave.
After some discussion, we've decided to abandon version comparison in favor of duck-style checking:
It doesn't require an extra dependency to parse versions.
It's more resistant to future changes (in case the change will be reverted).
Compatibility with Behave
We now try to access the tag_expression attribute first. If the attribute doesn't exist, the tags attribute is accessed instead.
Compatibility with pytest
We're checking the getfixturedefs signature. If the second parameter's annotation is str, it's provided with nodeid. Otherwise, it's provided with the node object itself. The inspection is only done once, on the first call to getfixturedefs. The remaining calls use the cached result of the check.
Additional changes
Log capturing tests
Log capturing tests for allure-pytest and allure-pytest-bdd now raise --log-level to WARNING instead of turning off the logging plugin when checking the case of disabled capturing. That prevents the unrecognized arguments: --log-level=INFO error when running against pytest 7.
CI actions update
As described here, actions that use Node.js version 16 are now deprecated. This PR updates such actions to the latest versions.
Flake config adjustment
This PR configs flake8 to ignore the new A005: the module is shadowing a Python builtin module rule for already existing modules allure_commons.types and allure-robotframework.listener.types.
Context
We currently have two occasions where we need to support backward incompatible changes in test frameworks:
Configuration.tags
withConfiguration.tag_expression
.FixtureManager.getfixturedefs
instead of thenodeid
string.We initially handled those by directly comparing Behave/pytest versions with
packaging.version.parse
.The solution works fine in allure-pytest since the
packaging
module is a transitive dependency of pytest.On the other hand, allure-behave crashes with
ModuleNotFoundError
unlesspackaging
becomes available either by hand or via some other package (e.g., setuptools). That happens becausepackaging
is missing in theinstall_requires
metadata ofallure-behave
.After some discussion, we've decided to abandon version comparison in favor of duck-style checking:
Compatibility with Behave
We now try to access the
tag_expression
attribute first. If the attribute doesn't exist, thetags
attribute is accessed instead.Compatibility with pytest
We're checking the
getfixturedefs
signature. If the second parameter's annotation isstr
, it's provided withnodeid
. Otherwise, it's provided with the node object itself. The inspection is only done once, on the first call togetfixturedefs
. The remaining calls use the cached result of the check.Additional changes
Log capturing tests
Log capturing tests for
allure-pytest
andallure-pytest-bdd
now raise --log-level to WARNING instead of turning off thelogging
plugin when checking the case of disabled capturing. That prevents theunrecognized arguments: --log-level=INFO
error when running against pytest 7.CI actions update
As described here, actions that use Node.js version 16 are now deprecated. This PR updates such actions to the latest versions.
Flake config adjustment
This PR configs flake8 to ignore the new
A005: the module is shadowing a Python builtin module
rule for already existing modulesallure_commons.types
andallure-robotframework.listener.types
.Fixes #802.