MCPcopy Index your code
hub / github.com/python/cpython / test_specific_shell

Method test_specific_shell

Lib/test/test_subprocess.py:2546–2564  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2544 self.assertEqual(rc, 47)
2545
2546 def test_specific_shell(self):
2547 # Issue #9265: Incorrect name passed as arg[0].
2548 shells = []
2549 for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']:
2550 for name in ['bash', 'ksh']:
2551 sh = os.path.join(prefix, name)
2552 if os.path.isfile(sh):
2553 shells.append(sh)
2554 if not shells: # Will probably work for any shell but csh.
2555 self.skipTest("bash or ksh required for this test")
2556 sh = '/bin/sh'
2557 if os.path.isfile(sh) and not os.path.islink(sh):
2558 # Test will fail if /bin/sh is a symlink to csh.
2559 shells.append(sh)
2560 for sh in shells:
2561 p = subprocess.Popen("echo $0", executable=sh, shell=True,
2562 stdout=subprocess.PIPE)
2563 with p:
2564 self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
2565
2566 def _kill_process(self, method, *args):
2567 # Do not inherit file handles from the parent.

Callers

nothing calls this directly

Calls 8

skipTestMethod · 0.80
islinkMethod · 0.80
joinMethod · 0.45
isfileMethod · 0.45
appendMethod · 0.45
assertEqualMethod · 0.45
stripMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected