mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
asyncio: Add an unit test to check that setting the PYTHONASYNCIODEBUG env var
enables debug mode of the event loop.
This commit is contained in:
parent
7b7120e159
commit
c082ee692b
2 changed files with 24 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ import sys
|
|||
import time
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from test.script_helper import assert_python_ok
|
||||
from test.support import IPV6_ENABLED
|
||||
|
||||
import asyncio
|
||||
|
|
@ -489,6 +490,29 @@ class BaseEventLoopTests(test_utils.TestCase):
|
|||
self.assertIs(type(_context['context']['exception']),
|
||||
ZeroDivisionError)
|
||||
|
||||
def test_env_var_debug(self):
|
||||
code = '\n'.join((
|
||||
'import asyncio',
|
||||
'loop = asyncio.get_event_loop()',
|
||||
'print(loop.get_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 MyProto(asyncio.Protocol):
|
||||
done = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue