File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353 import pty
5454except ImportError :
5555 pty = None
56+ try :
57+ import tkinter
58+ except ImportError :
59+ tkinter = None
5660
5761
5862class ReplTestCase (TestCase ):
@@ -1551,7 +1555,8 @@ def test_no_side_effects(self):
15511555 with (captured_stdout () as out ,
15521556 captured_stderr () as err ,
15531557 self ._capture_audit_events () as audit_events ,
1554- patch ("tkinter._tkinter.create" ) as tk_mock ,
1558+ (patch ("tkinter._tkinter.create" ) if tkinter
1559+ else contextlib .nullcontext ()) as tk_mock ,
15551560 warnings .catch_warnings (action = "ignore" ),
15561561 patch .dict (sys .modules )):
15571562 completer ._maybe_import_module (modname )
@@ -1562,7 +1567,8 @@ def test_no_side_effects(self):
15621567 # 2. spawn any subprocess (eg. webbrowser.open)
15631568 self .assertNotIn ("subprocess.Popen" , audit_events )
15641569 # 3. launch a Tk window
1565- tk_mock .assert_not_called ()
1570+ if tk_mock is not None :
1571+ tk_mock .assert_not_called ()
15661572
15671573
15681574class TestHardcodedSubmodules (TestCase ):
You can’t perform that action at this time.
0 commit comments