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 discussion in testing guide of how to reduce chances of getting test collection errors #2872

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

namurphy
Copy link
Member

When using pytest, I've noticed that it's harder to diagnose test collection errors than test failures (most recently in #2869 & #2870). Test collection errors don't result in good tracebacks, at least with the pytest settings from pyproject.toml. Test collection errors also prevent pytest from running the full test suite by default, which means we often get incomplete information.

In this PR, I'm planning to add some tips to the testing guide on how to avoid getting test collection errors. In particular, if a test file contains code that has a chance of failing, that code should be put into either a fixture or an actual test. Pretty much I want to avoid situations like...

# test_file.py

x = 0 / 0   # causes a ZeroDivisionError in the test collection phase

def test_something():
    assert True

I may also look into ways to improve the reporting of test collection errors.

Just wanted to start this PR now as a placeholder since it might take me a month or three to get to it.

@github-actions github-actions bot added docs PlasmaPy Docs at http://docs.plasmapy.org contributor guide labels Oct 25, 2024
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.17%. Comparing base (42d7a0b) to head (3c555dd).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2872      +/-   ##
==========================================
+ Coverage   95.12%   95.17%   +0.04%     
==========================================
  Files         107      107              
  Lines        9626     9634       +8     
  Branches     2230     2232       +2     
==========================================
+ Hits         9157     9169      +12     
+ Misses        280      277       -3     
+ Partials      189      188       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor guide docs PlasmaPy Docs at http://docs.plasmapy.org
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant