Skip to content

MNT: refactor tests to use cfradial1_sgp_dtree session fixture#347

Merged
aladinor merged 1 commit into
openradar:mainfrom
aladinor:ref/use-cfradial1-sgp-fixture
May 4, 2026
Merged

MNT: refactor tests to use cfradial1_sgp_dtree session fixture#347
aladinor merged 1 commit into
openradar:mainfrom
aladinor:ref/use-cfradial1-sgp-fixture

Conversation

@aladinor

Copy link
Copy Markdown
Member

Summary

  • Add cfradial1_sgp_dtree session fixture to conftest.py
  • Refactor 8 tests across test_util.py (6) and test_accessors.py (2) to use the shared fixture instead of inlining DATASETS.fetch("sample_sgp_data.nc") + open_cfradial1_datatree()
  • Net reduction: 76 lines removed

Closes #346

Test plan

  • All 128 tests in test_util.py + test_accessors.py pass
  • black + ruff clean

🤖 Generated with Claude Code

@codecov

codecov Bot commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.15%. Comparing base (e01a03d) to head (c001657).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #347   +/-   ##
=======================================
  Coverage   94.15%   94.15%           
=======================================
  Files          29       29           
  Lines        6416     6416           
=======================================
  Hits         6041     6041           
  Misses        375      375           
Flag Coverage Δ
notebooktests 0.00% <ø> (ø)
unittests 94.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kmuehlbauer kmuehlbauer 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.

@aladinor Thanks! One suggestion here.

Comment thread tests/conftest.py Outdated
@kmuehlbauer

Copy link
Copy Markdown
Collaborator

@aladinor Looks like this is almost done? Anything further needed here?

@aladinor

aladinor commented May 4, 2026

Copy link
Copy Markdown
Member Author

Ups. Totally forgot this. Let me address your comment @kmuehlbauer

aladinor added a commit to aladinor/xradar that referenced this pull request May 4, 2026
Address @kmuehlbauer's review on openradar#347. Returning the opened DataTree
from a session-scoped fixture forced tests that mutate the tree
(test_get_sweep_keys, test_map_over_sweeps_non_sweep_nodes) to call
.copy() defensively, and made cross-test mutation a possible source
of flakes. Return the filename instead and let each test open its
own DataTree.
@aladinor

aladinor commented May 4, 2026

Copy link
Copy Markdown
Member Author

@kmuehlbauer Good call — applied in c8dca43. The fixture now returns the filename and each test opens its own DataTree, dropping the defensive .copy() calls in test_get_sweep_keys and test_map_over_sweeps_non_sweep_nodes. All 128 tests in test_util + test_accessors still pass.

Closes openradar#346.

Add cfradial1_sgp_file session fixture in conftest.py that returns the
filename for sample_sgp_data.nc. Refactor 8 tests in test_util.py and
test_accessors.py to use the fixture instead of inlining
DATASETS.fetch + open_cfradial1_datatree.

Per @kmuehlbauer's review: the fixture returns the filename (not the
opened DataTree) so each test opens its own tree, avoiding cross-test
mutation that previously required defensive .copy() calls.

Tests covered:
- test_get_sweep_keys
- test_apply_to_sweeps
- test_apply_to_sweeps_inherit_false
- test_apply_to_sweeps_inherit_via_map_over_sweeps
- test_apply_to_volume
- test_map_over_sweeps_decorator_dummy_function
- test_map_over_sweeps_apply_dummy_function
- test_map_over_sweeps_non_sweep_nodes

132 tests in test_util.py + test_accessors.py pass; black + ruff clean.
@aladinor aladinor force-pushed the ref/use-cfradial1-sgp-fixture branch from c8dca43 to c001657 Compare May 4, 2026 15:52
@aladinor aladinor merged commit 279d33b into openradar:main May 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

REF: use cfradial1_sgp_dtree fixture in test_util.py and test_accessors.py

2 participants