File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5959 import readline as readline_module
6060except ImportError :
6161 readline_module = None
62+ try :
63+ import tkinter
64+ except ImportError :
65+ tkinter = None
6266
6367
6468class ReplTestCase (TestCase ):
@@ -1644,7 +1648,8 @@ def test_no_side_effects(self):
16441648 with (captured_stdout () as out ,
16451649 captured_stderr () as err ,
16461650 self ._capture_audit_events () as audit_events ,
1647- patch ("tkinter._tkinter.create" ) as tk_mock ,
1651+ (patch ("tkinter._tkinter.create" ) if tkinter
1652+ else contextlib .nullcontext ()) as tk_mock ,
16481653 warnings .catch_warnings (action = "ignore" ),
16491654 patch .dict (sys .modules )):
16501655 completer ._maybe_import_module (modname )
@@ -1655,7 +1660,8 @@ def test_no_side_effects(self):
16551660 # 2. spawn any subprocess (eg. webbrowser.open)
16561661 self .assertNotIn ("subprocess.Popen" , audit_events )
16571662 # 3. launch a Tk window
1658- tk_mock .assert_not_called ()
1663+ if tk_mock is not None :
1664+ tk_mock .assert_not_called ()
16591665
16601666
16611667class TestHardcodedSubmodules (TestCase ):
You can’t perform that action at this time.
0 commit comments