mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-37957: Allow regrtest to receive a file with test (and subtests) to ignore (GH-16989)
When building Python in some uncommon platforms there are some known tests that will fail. Right now, the test suite has the ability to ignore entire tests using the -x option and to receive a filter file using the --matchfile filter. The problem with the --matchfile option is that it receives a file with patterns to accept and when you want to ignore a couple of tests and subtests, is too cumbersome to lists ALL tests that are not the ones that you want to accept and he problem with -x is that is not easy to ignore just a subtests that fail and the whole test needs to be ignored. For these reasons, add a new option to allow to ignore a list of test and subtests for these situations.
This commit is contained in:
parent
ef5aa9af7c
commit
e0cd8aa70a
7 changed files with 169 additions and 24 deletions
|
@ -527,6 +527,7 @@ class TestSupport(unittest.TestCase):
|
|||
test_access = Test('test.test_os.FileTests.test_access')
|
||||
test_chdir = Test('test.test_os.Win32ErrorTests.test_chdir')
|
||||
|
||||
# Test acceptance
|
||||
with support.swap_attr(support, '_match_test_func', None):
|
||||
# match all
|
||||
support.set_match_tests([])
|
||||
|
@ -534,45 +535,92 @@ class TestSupport(unittest.TestCase):
|
|||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match all using None
|
||||
support.set_match_tests(None)
|
||||
support.set_match_tests(None, 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()])
|
||||
support.set_match_tests([test_access.id()], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# match the module name
|
||||
support.set_match_tests(['test_os'])
|
||||
support.set_match_tests(['test_os'], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# Test '*' pattern
|
||||
support.set_match_tests(['test_*'])
|
||||
support.set_match_tests(['test_*'], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# Test case sensitivity
|
||||
support.set_match_tests(['filetests'])
|
||||
support.set_match_tests(['filetests'], None)
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
support.set_match_tests(['FileTests'])
|
||||
support.set_match_tests(['FileTests'], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
|
||||
# Test pattern containing '.' and a '*' metacharacter
|
||||
support.set_match_tests(['*test_os.*.test_*'])
|
||||
support.set_match_tests(['*test_os.*.test_*'], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# Multiple patterns
|
||||
support.set_match_tests([test_access.id(), test_chdir.id()])
|
||||
support.set_match_tests([test_access.id(), test_chdir.id()], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
support.set_match_tests(['test_access', 'DONTMATCH'])
|
||||
support.set_match_tests(['test_access', 'DONTMATCH'], None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Test rejection
|
||||
with support.swap_attr(support, '_match_test_func', None):
|
||||
# match all
|
||||
support.set_match_tests(ignore_patterns=[])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match all using None
|
||||
support.set_match_tests(None, None)
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match the full test identifier
|
||||
support.set_match_tests(None, [test_access.id()])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
# match the module name
|
||||
support.set_match_tests(None, ['test_os'])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Test '*' pattern
|
||||
support.set_match_tests(None, ['test_*'])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Test case sensitivity
|
||||
support.set_match_tests(None, ['filetests'])
|
||||
self.assertTrue(support.match_test(test_access))
|
||||
support.set_match_tests(None, ['FileTests'])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
|
||||
# Test pattern containing '.' and a '*' metacharacter
|
||||
support.set_match_tests(None, ['*test_os.*.test_*'])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
# Multiple patterns
|
||||
support.set_match_tests(None, [test_access.id(), test_chdir.id()])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertFalse(support.match_test(test_chdir))
|
||||
|
||||
support.set_match_tests(None, ['test_access', 'DONTMATCH'])
|
||||
self.assertFalse(support.match_test(test_access))
|
||||
self.assertTrue(support.match_test(test_chdir))
|
||||
|
||||
def test_fd_count(self):
|
||||
# We cannot test the absolute value of fd_count(): on old Linux
|
||||
# kernel or glibc versions, os.urandom() keeps a FD open on
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue