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

Method test_special_chars_csh

Lib/test/test_venv.py:531–553  ·  view source on GitHub ↗

Test that the template strings are quoted properly (csh)

(self)

Source from the content-addressed store, hash-verified

529 @unittest.skipIf(sys.platform.startswith('netbsd'),
530 "NetBSD csh fails with quoted special chars; see gh-139308")
531 def test_special_chars_csh(self):
532 """
533 Test that the template strings are quoted properly (csh)
534 """
535 rmtree(self.env_dir)
536 csh = shutil.which('tcsh') or shutil.which('csh')
537 if csh is None:
538 self.skipTest('csh required for this test')
539 env_name = '"\';&&$e|\'"'
540 env_dir = os.path.join(os.path.realpath(self.env_dir), env_name)
541 builder = venv.EnvBuilder(clear=True)
542 builder.create(env_dir)
543 activate = os.path.join(env_dir, self.bindir, 'activate.csh')
544 test_script = os.path.join(self.env_dir, 'test_special_chars.csh')
545 with open(test_script, "w") as f:
546 f.write(f'source {shlex.quote(activate)}\n'
547 'python -c \'import sys; print(sys.executable)\'\n'
548 'python -c \'import os; print(os.environ["VIRTUAL_ENV"])\'\n'
549 'deactivate\n')
550 out, err = check_output([csh, test_script])
551 lines = out.splitlines()
552 self.assertTrue(env_name.encode() in lines[0])
553 self.assertEndsWith(lines[1], env_name.encode())
554
555 # gh-124651: test quoted strings on Windows
556 @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows')

Callers

nothing calls this directly

Calls 13

rmtreeFunction · 0.90
skipTestMethod · 0.80
quoteMethod · 0.80
assertTrueMethod · 0.80
assertEndsWithMethod · 0.80
check_outputFunction · 0.70
openFunction · 0.50
joinMethod · 0.45
realpathMethod · 0.45
createMethod · 0.45
writeMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected