File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414from py_discovery ._py_info import VersionInfo
1515
1616try :
17- import tkinter as tk # noqa: F401
18-
19- _HAS_TKINTER = True
17+ import tkinter as tk # pragma: no cover
2018except ImportError : # pragma: no cover
21- _HAS_TKINTER = False
19+ tk = None # type: ignore[assignment]
2220
2321if TYPE_CHECKING :
2422 from pathlib import Path
@@ -53,12 +51,10 @@ def test_get_tcl_tk_libs_returns_tuple() -> None:
5351 assert tk is None or isinstance (tk , str )
5452
5553
56- @pytest .mark .skipif (not _HAS_TKINTER , reason = "tkinter not available" )
57- def test_get_tcl_tk_libs_tcl_error (mocker ) -> None :
58- import tkinter as tk
59-
54+ @pytest .mark .skipif (tk is None , reason = "tkinter not available" )
55+ def test_get_tcl_tk_libs_tcl_error (mocker ) -> None : # pragma: no cover
6056 mock_tcl = MagicMock ()
61- mock_tcl .eval .side_effect = tk .TclError ("fail" )
57+ mock_tcl .eval .side_effect = tk .TclError ("fail" ) # type: ignore[union-attr]
6258 mocker .patch ("tkinter.Tcl" , return_value = mock_tcl )
6359
6460 tcl , _tk = PythonInfo ._get_tcl_tk_libs ()
You can’t perform that action at this time.
0 commit comments