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