Skip to content

Add pytest markers to separate fast tests from network/credential test - #118

Open
toakinrele wants to merge 4 commits into
mainfrom
pytest-fast-tests-115
Open

Add pytest markers to separate fast tests from network/credential test#118
toakinrele wants to merge 4 commits into
mainfrom
pytest-fast-tests-115

Conversation

@toakinrele

Copy link
Copy Markdown
Collaborator

Closes #115

Adds network and aws_creds pytest markers so the fast unit tests can be run separately from tests that need network access or AWS/GCS credentials.

  • Registered markers in pyproject.toml
  • conftest.py auto-tags tests based on which fixtures they use (download_gpkg, clean_s3_test, etc.), and auto-skips aws_creds
    tests when no AWS credentials are detected
  • Explicitly marked the handful of tests that hit the network directly without a fixture (test_hf2ds.py, some of test_trouterestarts.py)
  • Added a Makefile with test-fast / test-network / test-all targets

Local fast loop: make test-fast - 7 tests in ~3s instead of the full ~30 min suite, no credentials required.

@quinnylee quinnylee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is cool. I wonder if it would be possible to tease out some unit tests from all the integration tests that we have skipped? The fast test suite doesn't run anything from test_channelrouting.py, test_forcingprocessor.py, test_hf2ds.py, test_nrds_fp.py, or test_plotter.py

Comment thread tests/conftest.py
return bool(os.environ.get("AWS_PROFILE") or os.environ.get("AWS_SESSION_TOKEN"))


def pytest_collection_modifyitems(config, items):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is neat!

@toakinrele toakinrele Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For the five files you named, the tests are mostly thin wrappers (call hf2ds()/prep_ngen_data() with a real source, assert a file landed). The network call and the computation are fused inside those functions, so there's no clean pure logic to pull out without refactoring the source itself.

I did find three pure functions already sitting in processor.py (distribute_work, load_balance, calculate_vpu_precip_stats) that were only ever tested indirectly. Added direct unit tests for them, fast suite is now 18 tests, still ~3s. I also found a real bug in load_balance (it mishandles the all-zero-work case), so I marked it xfail with an explanation rather than fixing it here. (c6305c3)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe this is something we can delay until we merge the refactor branch?

Comment thread Makefile

@quinnylee quinnylee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the work! This topic (unit tests) will need to get revisited once we figure out what to do with the refactoring branch.

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.

Short test suite

3 participants