mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
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.
This commit is contained in:
parent
c745df8519
commit
6d9520c4f0
6 changed files with 37 additions and 26 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue