summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-23 00:19:33 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-06-23 00:19:33 +0200
commit5eca43eaeb602a9fb9edb701f6a01a52c416780c (patch)
treecf9a4155ae40c4d14636bf1e576a27473e68c0b6 /Lib/test/test_asyncio/test_base_events.py
parent9dcc25ce6e166c3ee632b93f84074e4261cac76c (diff)
downloadcpython-5eca43eaeb602a9fb9edb701f6a01a52c416780c.tar.gz
asyncio: Add an unit test to check that setting the PYTHONASYNCIODEBUG env var
enables debug mode of the event loop.
Diffstat (limited to 'Lib/test/test_asyncio/test_base_events.py')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 352af4887c..b238f4ea01 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -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