diff --git a/testsuite/MDAnalysisTests/topology/test_itp.py b/testsuite/MDAnalysisTests/topology/test_itp.py index 81a73cd331..8711ac072a 100644 --- a/testsuite/MDAnalysisTests/topology/test_itp.py +++ b/testsuite/MDAnalysisTests/topology/test_itp.py @@ -26,6 +26,7 @@ import numpy as np from numpy.testing import assert_allclose, assert_equal +from MDAnalysisTests.util import no_deprecated_call from MDAnalysisTests.topology.base import ParserBase from MDAnalysisTests.datafiles import ( ITP, # GROMACS itp @@ -490,6 +491,8 @@ def test_missing_elements_no_attribute(): u = mda.Universe(ITP_atomtypes) with pytest.raises(AttributeError): _ = u.atoms.elements + with no_deprecated_call(): + mda.Universe(ITP_atomtypes) def test_elements_deprecation_warning(): diff --git a/testsuite/MDAnalysisTests/util.py b/testsuite/MDAnalysisTests/util.py index 549a9f418a..88631bdcff 100644 --- a/testsuite/MDAnalysisTests/util.py +++ b/testsuite/MDAnalysisTests/util.py @@ -233,6 +233,11 @@ def _warn(self, message, category=None, *args, **kwargs): if isinstance(message, Warning): self._captured_categories.append(message.__class__) else: + # as follows Python documentation at + # https://docs.python.org/3/library/warnings.html#warnings.warn + # if category is None, the default UserWarning is used + if category is None: + category = UserWarning self._captured_categories.append(category) def __exit__(self, exc_type, exc_val, exc_tb):