Skip to content

Commit cc8a7a4

Browse files
committed
add test
1 parent dce74aa commit cc8a7a4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Lib/test/test_site.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,27 @@ def test_no_home_directory(self):
310310
mock_addsitedir.assert_not_called()
311311
self.assertFalse(known_paths)
312312

313+
def test_debug(self):
314+
def _run(input_):
315+
p = subprocess.Popen([sys.executable, "-c", "pass"], env=environ,
316+
stdin=subprocess.PIPE,
317+
stdout=subprocess.PIPE,
318+
stderr=subprocess.STDOUT)
319+
out, _ = p.communicate(b"c\n" if input_ else b"")
320+
return out
321+
re_pdb_prompt = rb"(?m)^\(Pdb\)\s*$"
322+
envvar = 'PYTHONSITEDEBUG'
323+
environ = os.environ.copy()
324+
325+
environ[envvar]="1"
326+
self.assertRegex(_run(True), re_pdb_prompt)
327+
environ[envvar]=""
328+
self.assertNotRegex(_run(False), re_pdb_prompt)
329+
del environ[envvar]
330+
self.assertNotRegex(_run(False), re_pdb_prompt)
331+
332+
333+
313334

314335
class PthFile(object):
315336
"""Helper class for handling testing of .pth files"""

0 commit comments

Comments
 (0)