summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-07-23 04:31:47 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-07-23 04:31:47 (GMT)
commit9adc1a38bda536e6f02fb5b3b1bbd231160a50de (patch)
treedb0ee59a186b7b96ed302f9b5677e58bb10a9e62
parent1fd497ed91a14eabaf37e9b3f17dde8c3169ef25 (diff)
downloadcpython-9adc1a38bda536e6f02fb5b3b1bbd231160a50de.zip
cpython-9adc1a38bda536e6f02fb5b3b1bbd231160a50de.tar.gz
cpython-9adc1a38bda536e6f02fb5b3b1bbd231160a50de.tar.bz2
Issue #13849: Add tests for null byte checking in test_genericpath
-rw-r--r--Lib/test/test_genericpath.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 86fc2de..d7644e8 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -274,6 +274,15 @@ class TestGenericTest(GenericTest, unittest.TestCase):
# 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).