From 129294152424257b29c06588ba63b1547ada123a Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Tue, 15 Nov 2016 11:11:27 +0100 Subject: [PATCH] get rid of side effect in test --- kwant/tests/test_plotter.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kwant/tests/test_plotter.py b/kwant/tests/test_plotter.py index fb21bea8..a21be99e 100644 --- a/kwant/tests/test_plotter.py +++ b/kwant/tests/test_plotter.py @@ -151,7 +151,7 @@ def test_map(): with warnings.catch_warnings(): warnings.simplefilter("ignore") plotter.map(sys.finalized(), xrange(len(sys.sites())), - file=out) + file=out) nose.tools.assert_raises(ValueError, plotter.map, sys, xrange(len(sys.sites())), file=out) @@ -160,7 +160,6 @@ def test_mask_interpolate(): # A coordinate array with coordinates of two points almost coinciding. coords = np.array([[0, 0], [1e-7, 1e-7], [1, 1], [1, 0]]) - warnings.simplefilter("ignore") with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") plotter.mask_interpolate(coords, np.ones(len(coords)), a=1) @@ -168,7 +167,9 @@ def test_mask_interpolate(): assert issubclass(w[-1].category, RuntimeWarning) assert "coinciding" in str(w[-1].message) - assert_raises(ValueError, plotter.mask_interpolate, - coords, np.ones(len(coords))) - assert_raises(ValueError, plotter.mask_interpolate, - coords, np.ones(2 * len(coords))) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + assert_raises(ValueError, plotter.mask_interpolate, + coords, np.ones(len(coords))) + assert_raises(ValueError, plotter.mask_interpolate, + coords, np.ones(2 * len(coords))) -- GitLab