Skip to content

Adds Pytest teardown to close figures#437

Merged
billbrod merged 5 commits into
mainfrom
pytest-teardown
May 20, 2026
Merged

Adds Pytest teardown to close figures#437
billbrod merged 5 commits into
mainfrom
pytest-teardown

Conversation

@billbrod
Copy link
Copy Markdown
Member

Describe the change in this PR at a high-level

This PR adds pytest fixtures so we can use them as a teardown to run after tests that create plots. This way we can close tests correctly (no matter how the test ends) and automatically (so we don't have to remember to add it to each test).

Also figured this out for doctests, where the proper thing to do is to add a conftest.py to the same directory tree as the doctests, i.e., the src/ folder. (See docs).

I have added the teardown:

  • to all doctests (with autouse)
  • to all tests in tests/test_display (with autouse)
  • to a select few tests in tests/test_models (without autouse, needs to be individually activated)

I could've just put it in test/conftest.py and automatically applied it to all tests, but the overwhelming majority of our tests don't create matplotlib figures, so that seems like overkill.

Checklist

Affirm that you have done the following:

  • I have described the changes in this PR, following the template above.
  • I have added any necessary tests.
  • I have added any necessary documentation. This includes docstrings, updates to existing files found in docs/, or (for large changes) adding new files to the docs/ folder.
  • If a public new class or function was added: I have double-checked that it is present in the API docs, adding it to one of the rst files in docs/api/ or adding a new file as necessary.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/plenoptic/conftest.py 0.00% 6 Missing ⚠️
Files with missing lines Coverage Δ
src/plenoptic/conftest.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@billbrod billbrod merged commit 5a288c9 into main May 20, 2026
23 of 24 checks passed
@billbrod billbrod deleted the pytest-teardown branch May 20, 2026 15:15
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.

1 participant