Skip to content

Commit caab85c

Browse files
committed
Fix some tests
1 parent e1eaffb commit caab85c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Lib/test/test_site.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,22 @@ def test_addpackage_empty_lines(self):
177177

178178
def test_addpackage_import_bad_pth_file(self):
179179
# Issue 5258
180+
# A .pth line with null bytes should not add anything to sys.path.
180181
pth_dir, pth_fn = self.make_pth("abc\x00def\n")
181-
with captured_stderr() as err_out:
182-
self.assertFalse(site.addpackage(pth_dir, pth_fn, set()))
183-
self.maxDiff = None
184-
self.assertEqual(err_out.getvalue(), "")
182+
site.addpackage(pth_dir, pth_fn, set())
185183
for path in sys.path:
186184
if isinstance(path, str):
187185
self.assertNotIn("abc\x00def", path)
188186

189187
def test_addsitedir(self):
190-
# Same tests for test_addpackage since addsitedir() essentially just
191-
# calls _read_pth_file() for every .pth file in the directory
188+
# addsitedir() reads .pth files and, when called standalone
189+
# (known_paths=None), flushes paths and import lines immediately.
192190
pth_file = PthFile()
193191
pth_file.cleanup(prep=True) # Make sure that nothing is pre-existing
194192
# that is tested for
195193
try:
196194
pth_file.create()
197-
site.addsitedir(pth_file.base_dir, set())
195+
site.addsitedir(pth_file.base_dir)
198196
self.pth_file_tests(pth_file)
199197
finally:
200198
pth_file.cleanup()

0 commit comments

Comments
 (0)