mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Issue #27063: Some unittest loader tests were silently skipped.
This commit is contained in:
parent
13e602ea0f
commit
0dad755600
1 changed files with 28 additions and 26 deletions
|
@ -8,7 +8,7 @@ import unittest
|
|||
# test isolation and reproducibility.
|
||||
def warningregistry(func):
|
||||
def wrapper(*args, **kws):
|
||||
missing = object()
|
||||
missing = []
|
||||
saved = getattr(warnings, '__warningregistry__', missing).copy()
|
||||
try:
|
||||
return func(*args, **kws)
|
||||
|
@ -20,6 +20,7 @@ def warningregistry(func):
|
|||
pass
|
||||
else:
|
||||
warnings.__warningregistry__ = saved
|
||||
return wrapper
|
||||
|
||||
|
||||
class Test_TestLoader(unittest.TestCase):
|
||||
|
@ -197,7 +198,7 @@ class Test_TestLoader(unittest.TestCase):
|
|||
# ignored (and deprecated).
|
||||
load_tests_args = []
|
||||
with warnings.catch_warnings(record=False):
|
||||
warnings.simplefilter('never')
|
||||
warnings.simplefilter('ignore')
|
||||
suite = loader.loadTestsFromModule(m, use_load_tests=False)
|
||||
self.assertEqual(load_tests_args, [loader, suite, None])
|
||||
|
||||
|
@ -274,7 +275,8 @@ class Test_TestLoader(unittest.TestCase):
|
|||
m.load_tests = load_tests
|
||||
loader = unittest.TestLoader()
|
||||
with self.assertRaises(TypeError) as cm, \
|
||||
warnings.catch_warning(record=True) as w:
|
||||
warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter('always')
|
||||
loader.loadTestsFromModule(m, False, 'testme.*')
|
||||
# We still got the deprecation warning.
|
||||
self.assertIs(w[-1].category, DeprecationWarning)
|
||||
|
@ -302,7 +304,7 @@ class Test_TestLoader(unittest.TestCase):
|
|||
m.load_tests = load_tests
|
||||
loader = unittest.TestLoader()
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('never')
|
||||
warnings.simplefilter('ignore')
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
loader.loadTestsFromModule(
|
||||
m, use_load_tests=False, very_bad=True, worse=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue