def pytest_configure(config): config.addinivalue_line( "markers", "qt_no_exception_capture: Disables pytest-qt's automatic exception " "capture for just one test item.", ) config.addinivalue_line( "markers", "qt_log_level_fail: overrides qt_log_level_fail ini option.") config.addinivalue_line( "markers", "qt_log_ignore: overrides qt_log_ignore ini option.") config.addinivalue_line("markers", "no_qt_log: Turn off Qt logging capture.") if config.getoption("qt_log") and config.getoption("capture") != "no": config.pluginmanager.register(QtLoggingPlugin(config), "_qt_logging") qt_api.set_qt_api(config.getini("qt_api")) if config.getini("qt_wait_signal_raising"): warnings.warn( "qt_wait_signal_raising is deprecated, use qt_default_raising instead.", DeprecationWarning, ) from .qtbot import QtBot QtBot._inject_qtest_methods()
def pytest_configure(config): config.addinivalue_line( "markers", "qt_no_exception_capture: Disables pytest-qt's automatic exception " "capture for just one test item.", ) config.addinivalue_line( "markers", "qt_log_level_fail: overrides qt_log_level_fail ini option." ) config.addinivalue_line( "markers", "qt_log_ignore: overrides qt_log_ignore ini option." ) config.addinivalue_line("markers", "no_qt_log: Turn off Qt logging capture.") if config.getoption("qt_log"): config.pluginmanager.register(QtLoggingPlugin(config), "_qt_logging") qt_api.set_qt_api(config.getini("qt_api")) if config.getini("qt_wait_signal_raising"): warnings.warn( "qt_wait_signal_raising is deprecated, use qt_default_raising instead.", DeprecationWarning, ) from .qtbot import QtBot QtBot._inject_qtest_methods()
def test_importerror(monkeypatch): def _fake_import(name, *args): raise ModuleNotFoundError(f"Failed to import {name}") monkeypatch.delenv("PYTEST_QT_API", raising=False) monkeypatch.setattr(qt_compat, "_import", _fake_import) expected = ("pytest-qt requires either PySide2 or PyQt5 installed.\n" " PyQt5.QtCore: Failed to import PyQt5.QtCore\n" " PySide2.QtCore: Failed to import PySide2.QtCore") with pytest.raises(RuntimeError, match=expected): qt_api.set_qt_api(api=None)
def test_importerror(monkeypatch): def _fake_import(name, *args): raise ImportError("Failed to import {}".format(name)) monkeypatch.delenv("PYTEST_QT_API", raising=False) monkeypatch.setattr(qt_compat, "_import", _fake_import) expected = ( "pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed\n" " PyQt4.QtCore: Failed to import PyQt4.QtCore\n" " PyQt5.QtCore: Failed to import PyQt5.QtCore\n" " PySide.QtCore: Failed to import PySide.QtCore\n" " PySide2.QtCore: Failed to import PySide2.QtCore") with pytest.raises(RuntimeError, match=expected): qt_api.set_qt_api(api=None)
def test_importerror(monkeypatch): def _fake_import(name, *args): raise ImportError("Failed to import {}".format(name)) monkeypatch.delenv("PYTEST_QT_API", raising=False) monkeypatch.setattr(qt_compat, "_import", _fake_import) expected = ( "pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed\n" " PyQt4.QtCore: Failed to import PyQt4.QtCore\n" " PyQt5.QtCore: Failed to import PyQt5.QtCore\n" " PySide.QtCore: Failed to import PySide.QtCore\n" " PySide2.QtCore: Failed to import PySide2.QtCore" ) with pytest.raises(RuntimeError, match=expected): qt_api.set_qt_api(api=None)
def pytest_configure(config): config.addinivalue_line( 'markers', "qt_no_exception_capture: Disables pytest-qt's automatic exception " 'capture for just one test item.') config.addinivalue_line( 'markers', 'qt_log_level_fail: overrides qt_log_level_fail ini option.') config.addinivalue_line( 'markers', 'qt_log_ignore: overrides qt_log_ignore ini option.') if config.getoption('qt_log'): config.pluginmanager.register(QtLoggingPlugin(config), '_qt_logging') qt_api.set_qt_api(config.getini('qt_api')) from .qtbot import QtBot QtBot._inject_qtest_methods()
def pytest_configure(config): config.addinivalue_line( "markers", "qt_no_exception_capture: Disables pytest-qt's automatic exception " "capture for just one test item.", ) config.addinivalue_line( "markers", "qt_log_level_fail: overrides qt_log_level_fail ini option." ) config.addinivalue_line( "markers", "qt_log_ignore: overrides qt_log_ignore ini option." ) config.addinivalue_line("markers", "no_qt_log: Turn off Qt logging capture.") if config.getoption("qt_log") and config.getoption("capture") != "no": config.pluginmanager.register(QtLoggingPlugin(config), "_qt_logging") qt_api.set_qt_api(config.getini("qt_api"))
def pytest_configure(config): config.addinivalue_line( 'markers', "qt_no_exception_capture: Disables pytest-qt's automatic exception " 'capture for just one test item.') config.addinivalue_line( 'markers', 'qt_log_level_fail: overrides qt_log_level_fail ini option.') config.addinivalue_line( 'markers', 'qt_log_ignore: overrides qt_log_ignore ini option.') if config.getoption('qt_log'): config.pluginmanager.register(QtLoggingPlugin(config), '_qt_logging') qt_api.set_qt_api(config.getini('qt_api')) from .qtbot import QtBot QtBot._inject_qtest_methods()