Skip to content

Commit

Permalink
Fix DeprecationWarning leading to test failure (#537)
Browse files Browse the repository at this point in the history
In test_simulationresult, a warnings filter is used which got
triggered by a DeprecationWarning in new versions of h5py (3.1.0).

This PR updates the filter to only catch UserWarnings; other
warning types will now be emitted normally.
  • Loading branch information
alubbock committed Mar 17, 2021
1 parent 6a88327 commit 39c5ac7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pysb/tests/test_simulationresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,9 @@ def test_save_load():
# Saving network free results requires include_obs_exprs=True,
# otherwise a warning should be raised
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
warnings.simplefilter("always", UserWarning)
nfres1.save(tf.name, dataset_name='nfsim_no_obs', append=True)
assert len(w) == 1
assert issubclass(w[-1].category, UserWarning)

nfres1.save(tf.name, include_obs_exprs=True,
dataset_name='nfsim test', append=True)
Expand Down

0 comments on commit 39c5ac7

Please sign in to comment.