diff --git a/gala/dynamics/mockstream/tests/test_mockstream.py b/gala/dynamics/mockstream/tests/test_mockstream.py index 992843853..514a9ecd4 100644 --- a/gala/dynamics/mockstream/tests/test_mockstream.py +++ b/gala/dynamics/mockstream/tests/test_mockstream.py @@ -82,17 +82,11 @@ def test_each_type(mock_func, extra_kwargs): # Test expected failures: # Deprecation warning for passing in potential - with warnings.catch_warnings(record=True) as wa: - warnings.simplefilter('always') - + warnings.simplefilter('always') + with pytest.warns(DeprecationWarning): stream = mock_func(potential, prog_orbit=prog, prog_mass=1E4*u.Msun, Integrator=DOPRI853Integrator, **extra_kwargs) - check = False - for www in wa: - check = check or issubclass(www.category, DeprecationWarning) - assert check - # Integrator not supported with pytest.raises(ValueError): stream = mock_func(potential, prog_orbit=prog, prog_mass=1E4*u.Msun, diff --git a/gala/dynamics/tests/test_core.py b/gala/dynamics/tests/test_core.py index a612018ad..146f6e754 100644 --- a/gala/dynamics/tests/test_core.py +++ b/gala/dynamics/tests/test_core.py @@ -145,15 +145,9 @@ def test_to_coord_frame(): coo,vel = o.to_coord_frame(Galactic) assert coo.name == 'galactic' - with warnings.catch_warnings(record=True) as wa: - warnings.simplefilter('always') + warnings.simplefilter('always') + with pytest.warns(DeprecationWarning): o.to_frame(Galactic) - # assert len(wa) == 1 - - check = False - for www in wa: - check = check or issubclass(www.category, DeprecationWarning) - assert check # doesn't work for 2D x = np.random.random(size=(2,10))*u.kpc @@ -214,15 +208,10 @@ def test_energy(): PE = o.potential_energy(p) E = o.energy(H) - with warnings.catch_warnings(record=True) as wa: - warnings.simplefilter('always') + warnings.simplefilter('always') + with pytest.warns(DeprecationWarning): o.energy(p) - check = False - for www in wa: - check = check or issubclass(www.category, DeprecationWarning) - assert check - def test_angular_momentum(): w = CartesianPhaseSpacePosition([1.,0.,0.], [0.,0.,1.])