|
10 | 10 | import tempfile |
11 | 11 | from test.support import script_helper, is_android |
12 | 12 | from test.support.script_helper import (spawn_python, kill_python, assert_python_ok, |
13 | | - assert_python_failure) |
| 13 | + assert_python_failure, interpreter_requires_environment) |
14 | 14 |
|
15 | 15 |
|
16 | 16 | # XXX (ncoghlan): Move to script_helper and make consistent with run_python |
@@ -57,6 +57,8 @@ def test_verbose(self): |
57 | 57 | rc, out, err = assert_python_ok('-vv') |
58 | 58 | self.assertNotIn(b'stack overflow', err) |
59 | 59 |
|
| 60 | + @unittest.skipIf(interpreter_requires_environment(), |
| 61 | + 'Cannot run -E tests when PYTHON env vars are required.') |
60 | 62 | def test_xoptions(self): |
61 | 63 | def get_xoptions(*args): |
62 | 64 | # use subprocess module directly because test.support.script_helper adds |
@@ -272,11 +274,7 @@ def test_empty_PYTHONPATH_issue16309(self): |
272 | 274 |
|
273 | 275 | def test_displayhook_unencodable(self): |
274 | 276 | for encoding in ('ascii', 'latin-1', 'utf-8'): |
275 | | - # We are testing a PYTHON environment variable here, so we can't |
276 | | - # use -E, -I, or script_helper (which uses them). So instead we do |
277 | | - # poor-man's isolation by deleting the PYTHON vars from env. |
278 | | - env = {key:value for (key,value) in os.environ.copy().items() |
279 | | - if not key.startswith('PYTHON')} |
| 277 | + env = os.environ.copy() |
280 | 278 | env['PYTHONIOENCODING'] = encoding |
281 | 279 | p = subprocess.Popen( |
282 | 280 | [sys.executable, '-i'], |
@@ -491,6 +489,7 @@ def test_isolatedmode(self): |
491 | 489 | cwd=tmpdir) |
492 | 490 | self.assertEqual(out.strip(), b"ok") |
493 | 491 |
|
| 492 | + |
494 | 493 | def test_main(): |
495 | 494 | test.support.run_unittest(CmdLineTest) |
496 | 495 | test.support.reap_children() |
|
0 commit comments