(self)
| 851 | @unittest.skipIf(check_sanitizer(address=True), |
| 852 | 'AddressSanitizer adds to the environment.') |
| 853 | def test_one_environment_variable(self): |
| 854 | newenv = {'fruit': 'orange'} |
| 855 | cmd = [sys.executable, '-c', |
| 856 | 'import sys,os;' |
| 857 | 'sys.stdout.write("fruit="+os.getenv("fruit"))'] |
| 858 | if sys.platform == "win32": |
| 859 | cmd = ["CMD", "/c", "SET", "fruit"] |
| 860 | with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=newenv) as p: |
| 861 | stdout, stderr = p.communicate() |
| 862 | if p.returncode and support.verbose: |
| 863 | print("STDOUT:", stdout.decode("ascii", "replace")) |
| 864 | print("STDERR:", stderr.decode("ascii", "replace")) |
| 865 | self.assertEqual(p.returncode, 0) |
| 866 | self.assertEqual(stdout.strip(), b"fruit=orange") |
| 867 | |
| 868 | def test_invalid_cmd(self): |
| 869 | # null character in the command name |
nothing calls this directly
no test coverage detected