Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with pytest version 8 #1177

Merged

Conversation

dm-ackerman
Copy link
Contributor

Description

Fixes a problem in deprecation handler that failed with version 8 of pytest

Upgraded to a version of pytest-markdown-docs that is compatible with pytest version 8.
That found several errors in the sample docs that have been fixed.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

The deprecated_handler() function is called by module level __getattr__
functions. It raised an ImportError when a module wasn't an env.
This breaks getattr's behaviour when it is called with a default
value. It expects __getattr__ to raise an AttributeError if the attr
is not found.

Pytest was apparently updated to call getattr(obj, key, default)
for several values of key. The import error isn't caught by getattr,
breaking the test.

Changing ImportError to AttributeError fixes this. The missing
attribute raises the correct error, which is caught by getattr,
which sets the value to the default and everything works as
intended.
The new version of pytest-markdon-docs caught several problems that the old version missed.
The examples now pass with the new version.
Required to work with version 8 of pytest
docs/index.md Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Copy link
Member

@elliottower elliottower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good besides the few things

@elliottower elliottower merged commit 616fc86 into Farama-Foundation:master Feb 15, 2024
47 checks passed
@dm-ackerman dm-ackerman deleted the pytest_v8_compatibility branch May 6, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants