mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
#16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work with unittest test discovery. Patch by Zachary Ware.
This commit is contained in:
parent
0c270a8bb7
commit
d0dfe9ad46
5 changed files with 15 additions and 27 deletions
|
|
@ -17,9 +17,7 @@ def safe_rmdir(dirname):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class GenericTest(unittest.TestCase):
|
class GenericTest:
|
||||||
# The path module to be tested
|
|
||||||
pathmodule = genericpath
|
|
||||||
common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime',
|
common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime',
|
||||||
'getmtime', 'exists', 'isdir', 'isfile']
|
'getmtime', 'exists', 'isdir', 'isfile']
|
||||||
attributes = []
|
attributes = []
|
||||||
|
|
@ -190,13 +188,16 @@ class GenericTest(unittest.TestCase):
|
||||||
support.unlink(support.TESTFN)
|
support.unlink(support.TESTFN)
|
||||||
safe_rmdir(support.TESTFN)
|
safe_rmdir(support.TESTFN)
|
||||||
|
|
||||||
|
class TestGenericTest(GenericTest, unittest.TestCase):
|
||||||
|
# Issue 16852: GenericTest can't inherit from unittest.TestCase
|
||||||
|
# for test discovery purposes; CommonTest inherits from GenericTest
|
||||||
|
# and is only meant to be inherited by others.
|
||||||
|
pathmodule = genericpath
|
||||||
|
|
||||||
# Following TestCase is not supposed to be run from test_genericpath.
|
# Following TestCase is not supposed to be run from test_genericpath.
|
||||||
# It is inherited by other test modules (macpath, ntpath, posixpath).
|
# It is inherited by other test modules (macpath, ntpath, posixpath).
|
||||||
|
|
||||||
class CommonTest(GenericTest):
|
class CommonTest(GenericTest):
|
||||||
# The path module to be tested
|
|
||||||
pathmodule = None
|
|
||||||
common_attributes = GenericTest.common_attributes + [
|
common_attributes = GenericTest.common_attributes + [
|
||||||
# Properties
|
# Properties
|
||||||
'curdir', 'pardir', 'extsep', 'sep',
|
'curdir', 'pardir', 'extsep', 'sep',
|
||||||
|
|
@ -328,9 +329,5 @@ class CommonTest(GenericTest):
|
||||||
self.test_abspath()
|
self.test_abspath()
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(GenericTest)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -115,13 +115,9 @@ class MacPathTestCase(unittest.TestCase):
|
||||||
self.assertEqual(normpath(b"a:b:"), b"a:b")
|
self.assertEqual(normpath(b"a:b:"), b"a:b")
|
||||||
|
|
||||||
|
|
||||||
class MacCommonTest(test_genericpath.CommonTest):
|
class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase):
|
||||||
pathmodule = macpath
|
pathmodule = macpath
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(MacPathTestCase, MacCommonTest)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -257,14 +257,10 @@ class TestNtpath(unittest.TestCase):
|
||||||
ntpath.sameopenfile(-1, -1)
|
ntpath.sameopenfile(-1, -1)
|
||||||
|
|
||||||
|
|
||||||
class NtCommonTest(test_genericpath.CommonTest):
|
class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase):
|
||||||
pathmodule = ntpath
|
pathmodule = ntpath
|
||||||
attributes = ['relpath', 'splitunc']
|
attributes = ['relpath', 'splitunc']
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(TestNtpath, NtCommonTest)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -524,14 +524,10 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
|
self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
|
||||||
|
|
||||||
|
|
||||||
class PosixCommonTest(test_genericpath.CommonTest):
|
class PosixCommonTest(test_genericpath.CommonTest, unittest.TestCase):
|
||||||
pathmodule = posixpath
|
pathmodule = posixpath
|
||||||
attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat']
|
attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat']
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(PosixPathTest, PosixCommonTest)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,9 @@ Library
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath
|
||||||
|
now work with unittest test discovery. Patch by Zachary Ware.
|
||||||
|
|
||||||
- Issue #16748: test_heapq now works with unittest test discovery.
|
- Issue #16748: test_heapq now works with unittest test discovery.
|
||||||
|
|
||||||
- Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize
|
- Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue