11"""
22Provide a common way to import Qt classes used by pytest-qt in a unique manner,
3- abstracting API differences between PyQt5/6 and PySide2/6 .
3+ abstracting API differences between PyQt5/6 and PySide6 .
44
55.. note:: This module is not part of pytest-qt public API, hence its interface
66may change between releases and users should not rely on it.
1919
2020QT_APIS = OrderedDict ()
2121QT_APIS ["pyside6" ] = "PySide6"
22- QT_APIS ["pyside2" ] = "PySide2"
2322QT_APIS ["pyqt6" ] = "PyQt6"
2423QT_APIS ["pyqt5" ] = "PyQt5"
2524
@@ -85,7 +84,7 @@ def set_qt_api(self, api):
8584 or self ._guess_qt_api ()
8685 )
8786
88- self .is_pyside = self .pytest_qt_api in ["pyside2" , " pyside6" ]
87+ self .is_pyside = self .pytest_qt_api in ["pyside6" ]
8988 self .is_pyqt = self .pytest_qt_api in ["pyqt5" , "pyqt6" ]
9089
9190 if not self .pytest_qt_api : # pragma: no cover
@@ -94,7 +93,7 @@ def set_qt_api(self, api):
9493 for module , reason in sorted (self ._import_errors .items ())
9594 )
9695 msg = (
97- "pytest-qt requires either PySide2, PySide6, PyQt5 or PyQt6 installed.\n "
96+ "pytest-qt requires either PySide6, PyQt5 or PyQt6 installed.\n "
9897 + errors
9998 )
10099 raise pytest .UsageError (msg )
@@ -112,7 +111,7 @@ def _import_module(module_name):
112111
113112 self ._check_qt_api_version ()
114113
115- # qInfo is not exposed in PySide2/6 (#232)
114+ # qInfo is not exposed in PySide6 (#232)
116115 if hasattr (QtCore , "QMessageLogger" ):
117116 self .qInfo = lambda msg : QtCore .QMessageLogger ().info (msg )
118117 elif hasattr (QtCore , "qInfo" ):
@@ -151,8 +150,8 @@ def _check_qt_api_version(self):
151150 )
152151
153152 def exec (self , obj , * args , ** kwargs ):
154- # exec was a keyword in Python 2, so PySide2 (and also PySide6 6.0)
155- # name the corresponding method "exec_" instead.
153+ # exec was a keyword in Python 2, so PySide6 6.0
154+ # names the corresponding method "exec_" instead.
156155 #
157156 # The old _exec() alias is removed in PyQt6 and also deprecated as of
158157 # PySide 6.1:
@@ -170,14 +169,6 @@ def get_versions(self):
170169 return VersionTuple (
171170 "PySide6" , version , self .QtCore .qVersion (), self .QtCore .__version__
172171 )
173- elif self .pytest_qt_api == "pyside2" :
174- import PySide2
175-
176- version = PySide2 .__version__
177-
178- return VersionTuple (
179- "PySide2" , version , self .QtCore .qVersion (), self .QtCore .__version__
180- )
181172 elif self .pytest_qt_api == "pyqt6" :
182173 return VersionTuple (
183174 "PyQt6" ,
0 commit comments