Skip to content

test: refactor tests, make xfail strict. - #1177

Merged
janfb merged 1 commit into
mainfrom
test-fix-slow-tests
Jun 20, 2024
Merged

janfb merged 1 commit into
mainfrom
test-fix-slow-tests

Conversation

@janfb

@janfb janfb commented Jun 18, 2024 •

Copy link
Copy Markdown
Contributor

I changed the pytest settings to xfail=strict. This means that when a test that is supposed to fail passes, this will results in a failure (was ignored before). This has the advantage that notice when a bug or missing feature was fixed "by accident" (see SNRE example below).

  • fix conditional sampling test
  • set fast mcmc args warmup steps=1
  • fix xpassing SNRE pickling test which was already fixed some time ago.

@codecov

codecov Bot commented Jun 18, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.92%. Comparing base (8efb8e4) to head (99c8778).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1177       +/-   ##
===========================================
- Coverage   83.69%   72.92%   -10.77%     
===========================================
  Files          93       94        +1     
  Lines        7397     7451       +54     
===========================================
- Hits         6191     5434      -757     
- Misses       1206     2017      +811     
Flag Coverage Δ
unittests 72.92% <ø> (-10.77%) ⬇️

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

see 26 files with indirect coverage changes

@janfb
janfb requested a review from manuelgloeckler June 18, 2024 15:29
Comment thread tests/density_estimator_test.py Resolved
Comment thread tests/linearGaussian_snpe_test.py Resolved
Comment thread tests/save_and_load_test.py Resolved
Comment thread tests/conftest.py Resolved

@manuelgloeckler manuelgloeckler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work 👍 🚀. I tested it locally it works like a charm.

Just one point, which is more one the pytest output. It will return (once intentionally triggered)

_________________________________________________________________________________________________________________________________ test_picklability[SNRE_B-vi] __________________________________________________________________________________________________________________________________
[XPASS(strict)] 
....
FAILED tests/save_and_load_test.py::test_picklability[SNRE_B-vi]
1 failed, 4 passed, 7 warnings in 1.83s

which does not give you much information why the test failed (just [XPASS(strict)] ).

Would be great if one could print out there something like "Expected failure but test passed". (Not sure if this is supported in pytest)

@janfb

janfb commented Jun 19, 2024

Copy link
Copy Markdown
Contributor Author

Great work 👍 🚀. I tested it locally it works like a charm.

Just one point, which is more one the pytest output. It will return (once intentionally triggered)

_________________________________________________________________________________________________________________________________ test_picklability[SNRE_B-vi] __________________________________________________________________________________________________________________________________
[XPASS(strict)] 
....
FAILED tests/save_and_load_test.py::test_picklability[SNRE_B-vi]
1 failed, 4 passed, 7 warnings in 1.83s

which does not give you much information why the test failed (just [XPASS(strict)] ).

Would be great if one could print out there something like "Expected failure but test passed". (Not sure if this is supported in pytest)

I agree that the output here is not so informative. It would be good to connect the FAILED with the corresponding XPASS. Not sure whether that's possible in the settings.

@janfb
janfb force-pushed the test-fix-slow-tests branch from 051ab1e to f3fffd2 Compare June 19, 2024 15:35
- fix conditional sampling test
- set fast mcmc args warmup steps=1
- fix SNRE pickling test
@janfb
janfb force-pushed the test-fix-slow-tests branch from f3fffd2 to 99c8778 Compare June 20, 2024 07:36
@janfb
janfb merged commit d76a085 into main Jun 20, 2024
@janfb
janfb deleted the test-fix-slow-tests branch June 20, 2024 07:59
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