|
7 | 7 | import time |
8 | 8 | import unittest |
9 | 9 | from unittest import mock |
| 10 | +from test.script_helper import assert_python_ok |
10 | 11 | from test.support import IPV6_ENABLED |
11 | 12 |
|
12 | 13 | import asyncio |
@@ -489,6 +490,29 @@ def custom_handler(loop, context): |
489 | 490 | self.assertIs(type(_context['context']['exception']), |
490 | 491 | ZeroDivisionError) |
491 | 492 |
|
| 493 | + def test_env_var_debug(self): |
| 494 | + code = '\n'.join(( |
| 495 | + 'import asyncio', |
| 496 | + 'loop = asyncio.get_event_loop()', |
| 497 | + 'print(loop.get_debug())')) |
| 498 | + |
| 499 | + # Test with -E to not fail if the unit test was run with |
| 500 | + # PYTHONASYNCIODEBUG set to a non-empty string |
| 501 | + sts, stdout, stderr = assert_python_ok('-E', '-c', code) |
| 502 | + self.assertEqual(stdout.rstrip(), b'False') |
| 503 | + |
| 504 | + sts, stdout, stderr = assert_python_ok('-c', code, |
| 505 | + PYTHONASYNCIODEBUG='') |
| 506 | + self.assertEqual(stdout.rstrip(), b'False') |
| 507 | + |
| 508 | + sts, stdout, stderr = assert_python_ok('-c', code, |
| 509 | + PYTHONASYNCIODEBUG='1') |
| 510 | + self.assertEqual(stdout.rstrip(), b'True') |
| 511 | + |
| 512 | + sts, stdout, stderr = assert_python_ok('-E', '-c', code, |
| 513 | + PYTHONASYNCIODEBUG='1') |
| 514 | + self.assertEqual(stdout.rstrip(), b'False') |
| 515 | + |
492 | 516 |
|
493 | 517 | class MyProto(asyncio.Protocol): |
494 | 518 | done = None |
|
0 commit comments