diff options
| author | Brett Cannon <bcannon@gmail.com> | 2006-12-13 23:09:53 (GMT) |
|---|---|---|
| committer | Brett Cannon <bcannon@gmail.com> | 2006-12-13 23:09:53 (GMT) |
| commit | 6d9520c4f0e01ff87ff3d74166f508df0a215261 (patch) | |
| tree | 4024486982a7efc6717ead6db1e0e44105bb27b6 /Lib/test/test_random.py | |
| parent | c745df8519b3dce95bb3ce7587c4c311f8184290 (diff) | |
| download | cpython-6d9520c4f0e01ff87ff3d74166f508df0a215261.zip cpython-6d9520c4f0e01ff87ff3d74166f508df0a215261.tar.gz cpython-6d9520c4f0e01ff87ff3d74166f508df0a215261.tar.bz2 | |
Add test.test_support.guard_warnings_filter . This function returns a context
manager that protects warnings.filter from being modified once the context is
exited.
Diffstat (limited to 'Lib/test/test_random.py')
| -rw-r--r-- | Lib/test/test_random.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index bba4c7c..e3f05a0 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -178,10 +178,9 @@ class WichmannHill_TestBasicOps(TestBasicOps): def test_bigrand(self): # Verify warnings are raised when randrange is too large for random() - oldfilters = warnings.filters[:] - warnings.filterwarnings("error", "Underlying random") - self.assertRaises(UserWarning, self.gen.randrange, 2**60) - warnings.filters[:] = oldfilters + with test_support.guard_warnings_filter(): + warnings.filterwarnings("error", "Underlying random") + self.assertRaises(UserWarning, self.gen.randrange, 2**60) class SystemRandom_TestBasicOps(TestBasicOps): gen = random.SystemRandom() |
