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

Method test_special_chars_windows

Lib/test/test_venv.py:557–577  ·  view source on GitHub ↗

Test that the template strings are quoted properly on Windows

(self)

Source from the content-addressed store, hash-verified

555 # gh-124651: test quoted strings on Windows
556 @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows')
557 def test_special_chars_windows(self):
558 """
559 Test that the template strings are quoted properly on Windows
560 """
561 rmtree(self.env_dir)
562 env_name = "'&&^$e"
563 env_dir = os.path.join(os.path.realpath(self.env_dir), env_name)
564 builder = venv.EnvBuilder(clear=True)
565 builder.create(env_dir)
566 activate = os.path.join(env_dir, self.bindir, 'activate.bat')
567 test_batch = os.path.join(self.env_dir, 'test_special_chars.bat')
568 with open(test_batch, "w") as f:
569 f.write('@echo off\n'
570 f'"{activate}" & '
571 f'{self.exe} -c "import sys; print(sys.executable)" & '
572 f'{self.exe} -c "import os; print(os.environ[\'VIRTUAL_ENV\'])" & '
573 'deactivate')
574 out, err = check_output([test_batch])
575 lines = out.splitlines()
576 self.assertTrue(env_name.encode() in lines[0])
577 self.assertEndsWith(lines[1], env_name.encode())
578
579 @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows')
580 def test_unicode_in_batch_file(self):

Callers

nothing calls this directly

Calls 11

rmtreeFunction · 0.90
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
encodeMethod · 0.45

Tested by

no test coverage detected