mirror of
https://github.com/python/cpython.git
synced 2025-08-29 21:25:01 +00:00
asyncio, Tulip issue #136: Add get/set_debug() methods to BaseEventLoopTests.
Add also a PYTHONASYNCIODEBUG environment variable to debug coroutines since Python startup, to be able to debug coroutines defined directly in the asyncio module.
This commit is contained in:
parent
f4558e8b54
commit
7ef60cd8c2
8 changed files with 83 additions and 5 deletions
|
@ -1,7 +1,9 @@
|
|||
"""Tests for tasks.py."""
|
||||
|
||||
import gc
|
||||
import os.path
|
||||
import unittest
|
||||
from test.script_helper import assert_python_ok
|
||||
|
||||
import asyncio
|
||||
from asyncio import test_utils
|
||||
|
@ -1461,6 +1463,32 @@ class GatherTestsBase:
|
|||
cb.assert_called_once_with(fut)
|
||||
self.assertEqual(fut.result(), [3, 1, exc, exc2])
|
||||
|
||||
def test_env_var_debug(self):
|
||||
path = os.path.dirname(asyncio.__file__)
|
||||
path = os.path.normpath(os.path.join(path, '..'))
|
||||
code = '\n'.join((
|
||||
'import sys',
|
||||
'sys.path.insert(0, %r)' % path,
|
||||
'import asyncio.tasks',
|
||||
'print(asyncio.tasks._DEBUG)'))
|
||||
|
||||
# Test with -E to not fail if the unit test was run with
|
||||
# PYTHONASYNCIODEBUG set to a non-empty string
|
||||
sts, stdout, stderr = assert_python_ok('-E', '-c', code)
|
||||
self.assertEqual(stdout.rstrip(), b'False')
|
||||
|
||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||
PYTHONASYNCIODEBUG='')
|
||||
self.assertEqual(stdout.rstrip(), b'False')
|
||||
|
||||
sts, stdout, stderr = assert_python_ok('-c', code,
|
||||
PYTHONASYNCIODEBUG='1')
|
||||
self.assertEqual(stdout.rstrip(), b'True')
|
||||
|
||||
sts, stdout, stderr = assert_python_ok('-E', '-c', code,
|
||||
PYTHONASYNCIODEBUG='1')
|
||||
self.assertEqual(stdout.rstrip(), b'False')
|
||||
|
||||
|
||||
class FutureGatherTests(GatherTestsBase, unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue