File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,6 @@ def __exit__(self, *exc):
42
42
if self .orig_trace :
43
43
sys .settrace (self .orig_trace )
44
44
45
- # To prevent a warning "test altered the execution environment" if
46
- # asyncio features are used.
47
- _set_event_loop_policy (None )
48
-
49
45
50
46
def test_pdb_displayhook ():
51
47
"""This tests the custom displayhook for pdb.
@@ -4675,13 +4671,33 @@ def func():
4675
4671
4676
4672
def load_tests (loader , tests , pattern ):
4677
4673
from test import test_pdb
4674
+
4678
4675
def setUpPdbBackend (backend ):
4679
4676
def setUp (test ):
4680
4677
import pdb
4681
4678
pdb .set_default_backend (backend )
4682
4679
return setUp
4683
- tests .addTest (doctest .DocTestSuite (test_pdb , setUp = setUpPdbBackend ('monitoring' )))
4684
- tests .addTest (doctest .DocTestSuite (test_pdb , setUp = setUpPdbBackend ('settrace' )))
4680
+
4681
+ def tearDown (test ):
4682
+ # Ensure that asyncio state has been cleared at the end of the test.
4683
+ # This prevents a "test altered the execution environment" warning if
4684
+ # asyncio features are used.
4685
+ _set_event_loop_policy (None )
4686
+
4687
+ tests .addTest (
4688
+ doctest .DocTestSuite (
4689
+ test_pdb ,
4690
+ setUp = setUpPdbBackend ('monitoring' ),
4691
+ tearDown = tearDown ,
4692
+ )
4693
+ )
4694
+ tests .addTest (
4695
+ doctest .DocTestSuite (
4696
+ test_pdb ,
4697
+ setUp = setUpPdbBackend ('settrace' ),
4698
+ tearDown = tearDown ,
4699
+ )
4700
+ )
4685
4701
return tests
4686
4702
4687
4703
You can’t perform that action at this time.
0 commit comments