Skip some tests that require a subinterpreter launched with -E or -I when the

interpreter under test is being run in an environment that requires the use of
environment variables such as PYTHONHOME in order to function at all.

Adds a private test.script_helper._interpreter_requires_environment() function
to be used with @unittest.skipIf on stdlib test methods requiring this.
This commit is contained in:
Gregory P. Smith 2015-02-04 00:59:40 -08:00
parent 17d87f8ae4
commit b9a3dd9dfb
4 changed files with 82 additions and 2 deletions

View file

@ -5,7 +5,7 @@ import tracemalloc
import unittest
from unittest.mock import patch
from test.script_helper import assert_python_ok, assert_python_failure
from test import support
from test import script_helper, support
try:
import threading
except ImportError:
@ -755,6 +755,8 @@ class TestCommandLine(unittest.TestCase):
stdout = stdout.rstrip()
self.assertEqual(stdout, b'False')
@unittest.skipIf(script_helper._interpreter_requires_environment(),
'Cannot run -E tests when PYTHON env vars are required.')
def test_env_var_ignored_with_E(self):
"""PYTHON* environment variables must be ignored when -E is present."""
code = 'import tracemalloc; print(tracemalloc.is_tracing())'