From 86a32cf12daac0c9ff24b50d187a61e63f5f5e38 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Wed, 29 Jan 2020 11:14:58 -0500 Subject: [PATCH] bpo-38937: add test --- Lib/test/test_site.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 41c42299195..f7621a0674c 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -167,6 +167,14 @@ class HelperFunctionsTests(unittest.TestCase): if isinstance(path, str): 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): # Same tests for test_addpackage since addsitedir() essentially just # calls addpackage() for every .pth file in the directory