mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-111165: Move test running code from test.support to libregrtest (GH-111166) (GH-111316)
Remove no longer used functions run_unittest() and run_doctest() from
the test.support module.
(cherry picked from commit f6a45a03d0
)
This commit is contained in:
parent
45c0b38880
commit
5c4f9a1c7e
12 changed files with 266 additions and 341 deletions
|
@ -550,120 +550,6 @@ class TestSupport(unittest.TestCase):
|
|||
with self.subTest(opts=opts):
|
||||
self.check_options(opts, 'optim_args_from_interpreter_flags')
|
||||
|
||||
def test_match_test(self):
|
||||
class Test:
|
||||
def __init__(self, test_id):
|
||||
self.test_id = test_id
|
||||
|
||||
def id(self):
|
||||
return self.test_id
|
||||
|
||||
test_access = Test('test.test_os.FileTests.test_access')
|
||||
test_chdir = Test('test.test_os.Win32ErrorTests.test_chdir')
|
||||
test_copy = Test('test.test_shutil.TestCopy.test_copy')
|
||||
|
||||
# Test acceptance
|
||||
with support.swap_attr(support, '_test_matchers', ()):
|
||||
# match all
|
||||
support.set_match_tests([])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match all using None
|
||||
support.set_match_tests(None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match the full test identifier
|
||||
support.set_match_tests([(test_access.id(), True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# match the module name
|
||||
support.set_match_tests([('test_os', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
self.assertFalse(support.match_test(test_copy))
|
||||
|
||||
# Test '*' pattern
|
||||
support.set_match_tests([('test_*', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# Test case sensitivity
|
||||
support.set_match_tests([('filetests', True)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
support.set_match_tests([('FileTests', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
|
||||
# Test pattern containing '.' and a '*' metacharacter
|
||||
support.set_match_tests([('*test_os.*.test_*', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
self.assertFalse(support.match_test(test_copy))
|
||||
|
||||
# Multiple patterns
|
||||
support.set_match_tests([(test_access.id(), True), (test_chdir.id(), True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
self.assertFalse(support.match_test(test_copy))
|
||||
|
||||
support.set_match_tests([('test_access', True), ('DONTMATCH', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Test rejection
|
||||
with support.swap_attr(support, '_test_matchers', ()):
|
||||
# match the full test identifier
|
||||
support.set_match_tests([(test_access.id(), False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match the module name
|
||||
support.set_match_tests([('test_os', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
self.assertTrue(support.match_test(test_copy))
|
||||
|
||||
# Test '*' pattern
|
||||
support.set_match_tests([('test_*', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Test case sensitivity
|
||||
support.set_match_tests([('filetests', False)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
support.set_match_tests([('FileTests', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
|
||||
# Test pattern containing '.' and a '*' metacharacter
|
||||
support.set_match_tests([('*test_os.*.test_*', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
self.assertTrue(support.match_test(test_copy))
|
||||
|
||||
# Multiple patterns
|
||||
support.set_match_tests([(test_access.id(), False), (test_chdir.id(), False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
self.assertTrue(support.match_test(test_copy))
|
||||
|
||||
support.set_match_tests([('test_access', False), ('DONTMATCH', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# Test mixed filters
|
||||
with support.swap_attr(support, '_test_matchers', ()):
|
||||
support.set_match_tests([('*test_os', False), ('test_access', True)])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
self.assertTrue(support.match_test(test_copy))
|
||||
|
||||
support.set_match_tests([('*test_os', True), ('test_access', False)])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
self.assertFalse(support.match_test(test_copy))
|
||||
|
||||
@unittest.skipIf(support.is_emscripten, "Unstable in Emscripten")
|
||||
@unittest.skipIf(support.is_wasi, "Unavailable on WASI")
|
||||
def test_fd_count(self):
|
||||
|
@ -864,7 +750,6 @@ class TestSupport(unittest.TestCase):
|
|||
# precisionbigmemtest
|
||||
# bigaddrspacetest
|
||||
# requires_resource
|
||||
# run_doctest
|
||||
# threading_cleanup
|
||||
# reap_threads
|
||||
# can_symlink
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue