mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
bpo-32101: Fix tests for PYTHONDEVMODE=1 (#4821)
test_asycio: remove also aio_path which was used when asyncio was developed outside the stdlib.
This commit is contained in:
parent
747f48e2e9
commit
721e25c653
3 changed files with 16 additions and 17 deletions
|
@ -802,17 +802,20 @@ class BaseEventLoopTests(test_utils.TestCase):
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||||
PYTHONASYNCIODEBUG='')
|
PYTHONASYNCIODEBUG='',
|
||||||
|
PYTHONDEVMODE='')
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||||
PYTHONASYNCIODEBUG='1')
|
PYTHONASYNCIODEBUG='1',
|
||||||
|
PYTHONDEVMODE='')
|
||||||
self.assertEqual(stdout.rstrip(), b'True')
|
self.assertEqual(stdout.rstrip(), b'True')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
||||||
PYTHONASYNCIODEBUG='1')
|
PYTHONASYNCIODEBUG='1')
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
|
# -X dev
|
||||||
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
|
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
|
||||||
'-c', code)
|
'-c', code)
|
||||||
self.assertEqual(stdout.rstrip(), b'True')
|
self.assertEqual(stdout.rstrip(), b'True')
|
||||||
|
|
|
@ -2257,33 +2257,31 @@ class GatherTestsBase:
|
||||||
self.assertEqual(fut.result(), [3, 1, exc, exc2])
|
self.assertEqual(fut.result(), [3, 1, exc, exc2])
|
||||||
|
|
||||||
def test_env_var_debug(self):
|
def test_env_var_debug(self):
|
||||||
aio_path = os.path.dirname(os.path.dirname(asyncio.__file__))
|
|
||||||
|
|
||||||
code = '\n'.join((
|
code = '\n'.join((
|
||||||
'import asyncio.coroutines',
|
'import asyncio.coroutines',
|
||||||
'print(asyncio.coroutines._DEBUG)'))
|
'print(asyncio.coroutines._DEBUG)'))
|
||||||
|
|
||||||
# Test with -E to not fail if the unit test was run with
|
# Test with -E to not fail if the unit test was run with
|
||||||
# PYTHONASYNCIODEBUG set to a non-empty string
|
# PYTHONASYNCIODEBUG set to a non-empty string
|
||||||
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
sts, stdout, stderr = assert_python_ok('-E', '-c', code)
|
||||||
PYTHONPATH=aio_path)
|
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||||
PYTHONASYNCIODEBUG='',
|
PYTHONASYNCIODEBUG='',
|
||||||
PYTHONPATH=aio_path)
|
PYTHONDEVMODE='')
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||||
PYTHONASYNCIODEBUG='1',
|
PYTHONASYNCIODEBUG='1',
|
||||||
PYTHONPATH=aio_path)
|
PYTHONDEVMODE='')
|
||||||
self.assertEqual(stdout.rstrip(), b'True')
|
self.assertEqual(stdout.rstrip(), b'True')
|
||||||
|
|
||||||
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
||||||
PYTHONASYNCIODEBUG='1',
|
PYTHONASYNCIODEBUG='1',
|
||||||
PYTHONPATH=aio_path)
|
PYTHONDEVMODE='')
|
||||||
self.assertEqual(stdout.rstrip(), b'False')
|
self.assertEqual(stdout.rstrip(), b'False')
|
||||||
|
|
||||||
|
# -X dev
|
||||||
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
|
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
|
||||||
'-c', code)
|
'-c', code)
|
||||||
self.assertEqual(stdout.rstrip(), b'True')
|
self.assertEqual(stdout.rstrip(), b'True')
|
||||||
|
|
|
@ -332,13 +332,9 @@ class FaultHandlerTests(unittest.TestCase):
|
||||||
def test_disabled_by_default(self):
|
def test_disabled_by_default(self):
|
||||||
# By default, the module should be disabled
|
# By default, the module should be disabled
|
||||||
code = "import faulthandler; print(faulthandler.is_enabled())"
|
code = "import faulthandler; print(faulthandler.is_enabled())"
|
||||||
args = filter(None, (sys.executable,
|
args = (sys.executable, "-E", "-c", code)
|
||||||
"-E" if sys.flags.ignore_environment else "",
|
|
||||||
"-c", code))
|
|
||||||
env = os.environ.copy()
|
|
||||||
env.pop("PYTHONFAULTHANDLER", None)
|
|
||||||
# don't use assert_python_ok() because it always enables faulthandler
|
# don't use assert_python_ok() because it always enables faulthandler
|
||||||
output = subprocess.check_output(args, env=env)
|
output = subprocess.check_output(args)
|
||||||
self.assertEqual(output.rstrip(), b"False")
|
self.assertEqual(output.rstrip(), b"False")
|
||||||
|
|
||||||
def test_sys_xoptions(self):
|
def test_sys_xoptions(self):
|
||||||
|
@ -357,15 +353,17 @@ class FaultHandlerTests(unittest.TestCase):
|
||||||
# empty env var
|
# empty env var
|
||||||
code = "import faulthandler; print(faulthandler.is_enabled())"
|
code = "import faulthandler; print(faulthandler.is_enabled())"
|
||||||
args = (sys.executable, "-c", code)
|
args = (sys.executable, "-c", code)
|
||||||
env = os.environ.copy()
|
env = dict(os.environ)
|
||||||
env['PYTHONFAULTHANDLER'] = ''
|
env['PYTHONFAULTHANDLER'] = ''
|
||||||
|
env['PYTHONDEVMODE'] = ''
|
||||||
# don't use assert_python_ok() because it always enables faulthandler
|
# don't use assert_python_ok() because it always enables faulthandler
|
||||||
output = subprocess.check_output(args, env=env)
|
output = subprocess.check_output(args, env=env)
|
||||||
self.assertEqual(output.rstrip(), b"False")
|
self.assertEqual(output.rstrip(), b"False")
|
||||||
|
|
||||||
# non-empty env var
|
# non-empty env var
|
||||||
env = os.environ.copy()
|
env = dict(os.environ)
|
||||||
env['PYTHONFAULTHANDLER'] = '1'
|
env['PYTHONFAULTHANDLER'] = '1'
|
||||||
|
env['PYTHONDEVMODE'] = ''
|
||||||
output = subprocess.check_output(args, env=env)
|
output = subprocess.check_output(args, env=env)
|
||||||
self.assertEqual(output.rstrip(), b"True")
|
self.assertEqual(output.rstrip(), b"True")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue