MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_special_chars_csh

Method test_special_chars_csh

Lib/test/test_venv.py:529–551  ·  view source on GitHub ↗

Test that the template strings are quoted properly (csh)

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected