diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -267,16 +267,25 @@ class GenericTest: 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 + def test_null_bytes(self): + for attr in GenericTest.common_attributes: + # os.path.commonprefix doesn't raise ValueError + if attr == 'commonprefix': + continue + with self.subTest(attr=attr): + with self.assertRaises(ValueError) as cm: + getattr(self.pathmodule, attr)('/tmp\x00abcds') + self.assertEqual(str(cm.exception), 'embedded null byte') # Following TestCase is not supposed to be run from test_genericpath. # It is inherited by other test modules (macpath, ntpath, posixpath). class CommonTest(GenericTest): common_attributes = GenericTest.common_attributes + [ # Properties 'curdir', 'pardir', 'extsep', 'sep',

AltStyle によって変換されたページ (->オリジナル) /