GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace version comparison with duck-style checks (fix #802) by delatrie · Pull Request #803 · allure-framework/allure-python

Conversation

@delatrie

@delatrie delatrie commented Apr 1, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Context

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:

  1. It doesn't require an extra dependency to parse versions.
  2. 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.

Fixes #802.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@delatrie delatrie added bug Something isn't working theme:pytest theme:behave labels Apr 1, 2024
@delatrie delatrie self-assigned this Apr 1, 2024
@delatrie
Revert behave compatibility check to duck style
c910384
@delatrie
delatrie force-pushed the bugfix-802-packaging branch from 9ba3bdb to c6f146a Compare April 1, 2024 14:38
@delatrie delatrie changed the title Add packaging to install_requires of allure-behave and allure-pytest (fix #802) Replace version compatison with duck-style checks (fix #802) Apr 1, 2024
@delatrie
delatrie requested a review from skhomuti April 1, 2024 15:22
@delatrie
delatrie marked this pull request as ready for review April 1, 2024 15:30
delatrie added 4 commits April 1, 2024 23:31
@delatrie
Replace pytest version check with signature test
15c8466
@delatrie
Fix unrecognized arguments error for log capturing tests
113e7f4
@delatrie
Ignore flake A005 on existing types modules
5ff6b78
@delatrie
Update CI actions to use node 20
3bc79f5
@delatrie
delatrie force-pushed the bugfix-802-packaging branch from 5cd6d6c to 3bc79f5 Compare April 1, 2024 16:32
skhomuti
skhomuti approved these changes Apr 1, 2024
View reviewed changes
@skhomuti skhomuti changed the title Replace version compatison with duck-style checks (fix #802) Replace version comparison with duck-style checks (fix #802) Apr 1, 2024
@delatrie
delatrie merged commit d857349 into master Apr 1, 2024
@delatrie
delatrie deleted the bugfix-802-packaging branch April 1, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@skhomuti skhomuti skhomuti approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@delatrie delatrie

Labels

bug Something isn't working theme:behave theme:pytest

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allure-behave 2.13.4 causes error with formatter in Python Behave

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@delatrie @skhomuti
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.