Replace version comparison with duck-style checks (fix #802) #803
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
We currently have two occasions where we need to support backward incompatible changes in test frameworks:
Configuration.tagswithConfiguration.tag_expression.FixtureManager.getfixturedefsinstead of thenodeidstring.We initially handled those by directly comparing Behave/pytest versions with
packaging.version.parse.The solution works fine in allure-pytest since the
packagingmodule is a transitive dependency of pytest.On the other hand, allure-behave crashes with
ModuleNotFoundErrorunlesspackagingbecomes available either by hand or via some other package (e.g., setuptools). That happens becausepackagingis missing in theinstall_requiresmetadata 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_expressionattribute first. If the attribute doesn't exist, thetagsattribute is accessed instead.Compatibility with pytest
We're checking the
getfixturedefssignature. 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-pytestandallure-pytest-bddnow raise --log-level to WARNING instead of turning off theloggingplugin when checking the case of disabled capturing. That prevents theunrecognized arguments: --log-level=INFOerror 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 modulerule for already existing modulesallure_commons.typesandallure-robotframework.listener.types.Fixes #802.