Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 721e25c

Browse files
authored
bpo-32101: Fix tests for PYTHONDEVMODE=1 (#4821)
test_asycio: remove also aio_path which was used when asyncio was developed outside the stdlib.
1 parent 747f48e commit 721e25c

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

Lib/test/test_asyncio/test_base_events.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,17 +802,20 @@ def test_env_var_debug(self):
802802
self.assertEqual(stdout.rstrip(), b'False')
803803

804804
sts, stdout, stderr = assert_python_ok('-c', code,
805-
PYTHONASYNCIODEBUG='')
805+
PYTHONASYNCIODEBUG='',
806+
PYTHONDEVMODE='')
806807
self.assertEqual(stdout.rstrip(), b'False')
807808

808809
sts, stdout, stderr = assert_python_ok('-c', code,
809-
PYTHONASYNCIODEBUG='1')
810+
PYTHONASYNCIODEBUG='1',
811+
PYTHONDEVMODE='')
810812
self.assertEqual(stdout.rstrip(), b'True')
811813

812814
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
813815
PYTHONASYNCIODEBUG='1')
814816
self.assertEqual(stdout.rstrip(), b'False')
815817

818+
# -X dev
816819
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
817820
'-c', code)
818821
self.assertEqual(stdout.rstrip(), b'True')

Lib/test/test_asyncio/test_tasks.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,33 +2257,31 @@ def test_return_exceptions(self):
22572257
self.assertEqual(fut.result(), [3, 1, exc, exc2])
22582258

22592259
def test_env_var_debug(self):
2260-
aio_path = os.path.dirname(os.path.dirname(asyncio.__file__))
2261-
22622260
code = '\n'.join((
22632261
'import asyncio.coroutines',
22642262
'print(asyncio.coroutines._DEBUG)'))
22652263

22662264
# Test with -E to not fail if the unit test was run with
22672265
# PYTHONASYNCIODEBUG set to a non-empty string
2268-
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
2269-
PYTHONPATH=aio_path)
2266+
sts, stdout, stderr = assert_python_ok('-E', '-c', code)
22702267
self.assertEqual(stdout.rstrip(), b'False')
22712268

22722269
sts, stdout, stderr = assert_python_ok('-c', code,
22732270
PYTHONASYNCIODEBUG='',
2274-
PYTHONPATH=aio_path)
2271+
PYTHONDEVMODE='')
22752272
self.assertEqual(stdout.rstrip(), b'False')
22762273

22772274
sts, stdout, stderr = assert_python_ok('-c', code,
22782275
PYTHONASYNCIODEBUG='1',
2279-
PYTHONPATH=aio_path)
2276+
PYTHONDEVMODE='')
22802277
self.assertEqual(stdout.rstrip(), b'True')
22812278

22822279
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
22832280
PYTHONASYNCIODEBUG='1',
2284-
PYTHONPATH=aio_path)
2281+
PYTHONDEVMODE='')
22852282
self.assertEqual(stdout.rstrip(), b'False')
22862283

2284+
# -X dev
22872285
sts, stdout, stderr = assert_python_ok('-E', '-X', 'dev',
22882286
'-c', code)
22892287
self.assertEqual(stdout.rstrip(), b'True')

Lib/test/test_faulthandler.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,9 @@ def test_is_enabled(self):
332332
def test_disabled_by_default(self):
333333
# By default, the module should be disabled
334334
code = "import faulthandler; print(faulthandler.is_enabled())"
335-
args = filter(None, (sys.executable,
336-
"-E" if sys.flags.ignore_environment else "",
337-
"-c", code))
338-
env = os.environ.copy()
339-
env.pop("PYTHONFAULTHANDLER", None)
335+
args = (sys.executable, "-E", "-c", code)
340336
# don't use assert_python_ok() because it always enables faulthandler
341-
output = subprocess.check_output(args, env=env)
337+
output = subprocess.check_output(args)
342338
self.assertEqual(output.rstrip(), b"False")
343339

344340
def test_sys_xoptions(self):
@@ -357,15 +353,17 @@ def test_env_var(self):
357353
# empty env var
358354
code = "import faulthandler; print(faulthandler.is_enabled())"
359355
args = (sys.executable, "-c", code)
360-
env = os.environ.copy()
356+
env = dict(os.environ)
361357
env['PYTHONFAULTHANDLER'] = ''
358+
env['PYTHONDEVMODE'] = ''
362359
# don't use assert_python_ok() because it always enables faulthandler
363360
output = subprocess.check_output(args, env=env)
364361
self.assertEqual(output.rstrip(), b"False")
365362

366363
# non-empty env var
367-
env = os.environ.copy()
364+
env = dict(os.environ)
368365
env['PYTHONFAULTHANDLER'] = '1'
366+
env['PYTHONDEVMODE'] = ''
369367
output = subprocess.check_output(args, env=env)
370368
self.assertEqual(output.rstrip(), b"True")
371369

0 commit comments

Comments
 (0)