bpo-38937: add test

This commit is contained in:
chrisjbillington 2020-01-29 11:14:58 -05:00
parent 49282fd672
commit 86a32cf12d
1 changed files with 8 additions and 0 deletions

View File

@ -167,6 +167,14 @@ class HelperFunctionsTests(unittest.TestCase):
if isinstance(path, str): if isinstance(path, str):
self.assertNotIn("abc\x00def", path) self.assertNotIn("abc\x00def", path)
def test_pth_exc_namespacing(self):
# Issue 38937
contents = "import sys; x = 5; [print(x + i) for i in range(5)]\n"
pth_dir, pth_fn = self.make_pth(contents)
with captured_stderr() as err_out:
self.assertFalse(site.addpackage(pth_dir, pth_fn, set()))
self.assertEqual(err_out.getvalue(), "")
def test_addsitedir(self): def test_addsitedir(self):
# Same tests for test_addpackage since addsitedir() essentially just # Same tests for test_addpackage since addsitedir() essentially just
# calls addpackage() for every .pth file in the directory # calls addpackage() for every .pth file in the directory