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

Method test_special_chars_bash

Lib/test/test_venv.py:501–523  ·  view source on GitHub ↗

Test that the template strings are quoted properly (bash)

(self)

Source from the content-addressed store, hash-verified

499 # gh-124651: test quoted strings
500 @unittest.skipIf(os.name == 'nt', 'contains invalid characters on Windows')
501 def test_special_chars_bash(self):
502 """
503 Test that the template strings are quoted properly (bash)
504 """
505 rmtree(self.env_dir)
506 bash = shutil.which('bash')
507 if bash is None:
508 self.skipTest('bash required for this test')
509 env_name = '"\';&&$e|\'"'
510 env_dir = os.path.join(os.path.realpath(self.env_dir), env_name)
511 builder = venv.EnvBuilder(clear=True)
512 builder.create(env_dir)
513 activate = os.path.join(env_dir, self.bindir, 'activate')
514 test_script = os.path.join(self.env_dir, 'test_special_chars.sh')
515 with open(test_script, "w") as f:
516 f.write(f'source {shlex.quote(activate)}\n'
517 'python -c \'import sys; print(sys.executable)\'\n'
518 'python -c \'import os; print(os.environ["VIRTUAL_ENV"])\'\n'
519 'deactivate\n')
520 out, err = check_output([bash, test_script])
521 lines = out.splitlines()
522 self.assertTrue(env_name.encode() in lines[0])
523 self.assertEndsWith(lines[1], env_name.encode())
524
525 # gh-124651: test quoted strings
526 @unittest.skipIf(os.name == 'nt', 'contains invalid characters 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