Skip to content

Commit dd4ad43

Browse files
committed
Remove use of imp
1 parent 9a7cf78 commit dd4ad43

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import re
77
import sys
8-
import imp
8+
import importlib.util
99
import shutil
1010
import tempfile
1111
import textwrap
@@ -452,11 +452,15 @@ def test_environment():
452452

453453
if sys.version_info >= (3, 11):
454454
# NOTE: Qt6 is only available for python 3.11 and above
455-
imp.find_module("PySide6")
456-
imp.find_module("PyQt6")
455+
if importlib.util.find_spec("PySide6") is None:
456+
raise ImportError("No module named 'PySide6'")
457+
if importlib.util.find_spec("PyQt6") is None:
458+
raise ImportError("No module named 'PyQt6'")
457459
else:
458-
imp.find_module("PySide2")
459-
imp.find_module("PyQt5")
460+
if importlib.util.find_spec("PySide2") is None:
461+
raise ImportError("No module named 'PySide2'")
462+
if importlib.util.find_spec("PyQt5") is None:
463+
raise ImportError("No module named 'PyQt5'")
460464

461465

462466
def test_load_ui_returntype():

0 commit comments

Comments
 (0)