HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/qtpy/tests/test_missing_optional_deps.py
"""Test the deferred import error mechanism"""


# See https://github.com/spyder-ide/qtpy/pull/387/


import pytest

from qtpy import QtModuleNotInstalledError


def test_missing_optional_deps():
    """Test importing a module that uses the deferred import error mechanism"""
    from . import optional_deps

    assert optional_deps.ExampleClass is not None

    with pytest.raises(QtModuleNotInstalledError) as excinfo:
        from .optional_deps import MissingClass

    msg = "The optional_dep.MissingClass module was not found. It must be installed separately as test_package_please_ignore."
    assert msg == str(excinfo.value)