Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 tests fail #457

Open
yurivict opened this issue Oct 8, 2022 · 3 comments
Open

3 tests fail #457

yurivict opened this issue Oct 8, 2022 · 3 comments

Comments

@yurivict
Copy link

yurivict commented Oct 8, 2022

========================================================================================== FAILURES ==========================================================================================
_________________________________________________________________________________ test_logging_fails_ignore __________________________________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0')>

    def test_logging_fails_ignore(testdir):
        """
        Test qt_log_ignore config option.
    
        :type testdir: _pytest.pytester.TmpTestdir
        """
        testdir.makeini(
            """
            [pytest]
            qt_log_level_fail = CRITICAL
            qt_log_ignore =
                WM_DESTROY.*sent
                WM_PAINT not handled
            """
        )
        testdir.makepyfile(
            """
            from pytestqt.qt_compat import qt_api
            import pytest
    
            def test1():
                qt_api.qCritical('a critical message')
            def test2():
                qt_api.qCritical('WM_DESTROY was sent')
            def test3():
                qt_api.qCritical('WM_DESTROY was sent')
                assert 0
            def test4():
                qt_api.qCritical('WM_PAINT not handled')
                qt_api.qCritical('another critical message')
            """
        )
        res = testdir.runpytest()
        lines = [
            # test1 fails because it has emitted a CRITICAL message and that message
            # does not match any regex in qt_log_ignore
            "*_ test1 _*",
            "*Failure: Qt messages with level CRITICAL or above emitted*",
            "*QtCriticalMsg: a critical message*",
            # test2 succeeds because its message matches qt_log_ignore
            # test3 fails because of an assert, but the ignored message should
            # still appear in the failure message
            "*_ test3 _*",
            "*AssertionError*",
            "*QtCriticalMsg: WM_DESTROY was sent*(IGNORED)*",
            # test4 fails because one message is ignored but the other isn't
            "*_ test4 _*",
            "*Failure: Qt messages with level CRITICAL or above emitted*",
            "*QtCriticalMsg: WM_PAINT not handled*(IGNORED)*",
            "*QtCriticalMsg: another critical message*",
            # summary
            "*3 failed, 1 passed*",
        ]
>       res.stdout.fnmatch_lines(lines)
E       Failed: nomatch: '*_ test1 _*'
E           and: '============================= test session starts =============================='
E           and: 'platform freebsd13 -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0'
E           and: 'PyQt5 5.15.6 -- Qt runtime 5.15.5 -- Qt compiled 5.15.5'
E           and: 'Using --randomly-seed=3508469783'
E           and: 'rootdir: /tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0, configfile: tox.ini'
E           and: 'plugins: qt-4.1.0, forked-1.4.0, hypothesis-6.55.0, cov-2.9.0, rerunfailures-10.1, xdist-2.5.0, randomly-3.12.0, typeguard-2.13.3'
E           and: 'collected 4 items'
E           and: ''
E           and: 'test_logging_fails_ignore.py F.FF                                        [100%]'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '____________________________________ test3 _____________________________________'
E           and: ''
E           and: '    def test3():'
E           and: "        qt_api.qCritical('WM_DESTROY was sent')"
E           and: '>       assert 0'
E           and: 'E       assert 0'
E           and: ''
E           and: 'test_logging_fails_ignore.py:10: AssertionError'
E           and: '----------------------------- Captured Qt messages -----------------------------'
E           and: '/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test3:9:'
E           and: ''
E           and: '    QtCriticalMsg: WM_DESTROY was sent (IGNORED)'
E       fnmatch: '*_ test1 _*'
E          with: '____________________________________ test1 _____________________________________'
E       fnmatch: '*Failure: Qt messages with level CRITICAL or above emitted*'
E          with: 'test_logging_fails_ignore.py:4: Failure: Qt messages with level CRITICAL or above emitted'
E       nomatch: '*QtCriticalMsg: a critical message*'
E           and: '----------------------------- Captured Qt messages -----------------------------'
E           and: '/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test1:5:'
E           and: ''
E       fnmatch: '*QtCriticalMsg: a critical message*'
E          with: '    QtCriticalMsg: a critical message'
E       nomatch: '*_ test3 _*'
E           and: '____________________________________ test4 _____________________________________'
E           and: 'test_logging_fails_ignore.py:11: Failure: Qt messages with level CRITICAL or above emitted'
E           and: '----------------------------- Captured Qt messages -----------------------------'
E           and: '/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test4:12:'
E           and: ''
E           and: '    QtCriticalMsg: WM_PAINT not handled (IGNORED)'
E           and: '/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test4:13:'
E           and: ''
E           and: '    QtCriticalMsg: another critical message'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_logging_fails_ignore.py::test3 - assert 0'
E           and: 'FAILED test_logging_fails_ignore.py::test1'
E           and: 'FAILED test_logging_fails_ignore.py::test4'
E           and: '========================= 3 failed, 1 passed in 0.04s =========================='
E       remains unmatched: '*_ test3 _*'

/disk-samsung/freebsd-ports/devel/py-pytest-qt/work-py39/pytest-qt-4.1.0/tests/test_logging.py:339: Failed
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform freebsd13 -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0
PyQt5 5.15.6 -- Qt runtime 5.15.5 -- Qt compiled 5.15.5
Using --randomly-seed=3508469783
rootdir: /tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0, configfile: tox.ini
plugins: qt-4.1.0, forked-1.4.0, hypothesis-6.55.0, cov-2.9.0, rerunfailures-10.1, xdist-2.5.0, randomly-3.12.0, typeguard-2.13.3
collected 4 items

test_logging_fails_ignore.py F.FF                                        [100%]

=================================== FAILURES ===================================
____________________________________ test3 _____________________________________

    def test3():
        qt_api.qCritical('WM_DESTROY was sent')
>       assert 0
E       assert 0

test_logging_fails_ignore.py:10: AssertionError
----------------------------- Captured Qt messages -----------------------------
/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test3:9:

    QtCriticalMsg: WM_DESTROY was sent (IGNORED)
____________________________________ test1 _____________________________________
test_logging_fails_ignore.py:4: Failure: Qt messages with level CRITICAL or above emitted
----------------------------- Captured Qt messages -----------------------------
/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test1:5:

    QtCriticalMsg: a critical message
____________________________________ test4 _____________________________________
test_logging_fails_ignore.py:11: Failure: Qt messages with level CRITICAL or above emitted
----------------------------- Captured Qt messages -----------------------------
/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test4:12:

    QtCriticalMsg: WM_PAINT not handled (IGNORED)
/tmp/pytest-of-yuri/pytest-0/test_logging_fails_ignore0/test_logging_fails_ignore.py:test4:13:

    QtCriticalMsg: another critical message
=========================== short test summary info ============================
FAILED test_logging_fails_ignore.py::test3 - assert 0
FAILED test_logging_fails_ignore.py::test1
FAILED test_logging_fails_ignore.py::test4
========================= 3 failed, 1 passed in 0.04s ==========================
_________________________________________________________________________________ test_exceptions_dont_leak __________________________________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0')>

    @pytest.mark.xfail(
        condition=sys.version_info[:2] == (3, 4),
        reason="failing in Python 3.4, which is about to be dropped soon anyway",
    )
    def test_exceptions_dont_leak(testdir):
        """
        Ensure exceptions are cleared when an exception occurs and don't leak (#187).
        """
        testdir.makepyfile(
            """
            from pytestqt.qt_compat import qt_api
            import gc
            import weakref
    
            class MyWidget(qt_api.QtWidgets.QWidget):
    
                def event(self, ev):
                    called.append(1)
                    raise RuntimeError('event processed')
    
            weak_ref = None
            called = []
    
            def test_1(qapp):
                global weak_ref
                w = MyWidget()
                weak_ref = weakref.ref(w)
                qapp.postEvent(w, qt_api.QtCore.QEvent(qt_api.QtCore.QEvent.Type.User))
                qapp.processEvents()
    
            def test_2(qapp):
                assert called
                gc.collect()
                assert weak_ref() is None
        """
        )
        result = testdir.runpytest()
>       result.stdout.fnmatch_lines(["*1 failed, 1 passed*"])
E       Failed: nomatch: '*1 failed, 1 passed*'
E           and: '============================= test session starts =============================='
E           and: 'platform freebsd13 -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0'
E           and: 'PyQt5 5.15.6 -- Qt runtime 5.15.5 -- Qt compiled 5.15.5'
E           and: 'Using --randomly-seed=3508469783'
E           and: 'rootdir: /tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0'
E           and: 'plugins: qt-4.1.0, forked-1.4.0, hypothesis-6.55.0, cov-2.9.0, rerunfailures-10.1, xdist-2.5.0, randomly-3.12.0, typeguard-2.13.3'
E           and: 'collected 2 items'
E           and: ''
E           and: 'test_exceptions_dont_leak.py FF                                          [100%]'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '____________________________________ test_2 ____________________________________'
E           and: ''
E           and: 'qapp = <PyQt5.QtWidgets.QApplication object at 0x8fc7e2430>'
E           and: ''
E           and: '    def test_2(qapp):'
E           and: '>       assert called'
E           and: 'E       assert []'
E           and: ''
E           and: 'test_exceptions_dont_leak.py:22: AssertionError'
E           and: '____________________________________ test_1 ____________________________________'
E           and: 'CALL ERROR: Exceptions caught in Qt event loop:'
E           and: '________________________________________________________________________________'
E           and: 'Traceback (most recent call last):'
E           and: '  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event'
E           and: "    raise RuntimeError('event processed')"
E           and: 'RuntimeError: event processed'
E           and: '________________________________________________________________________________'
E           and: 'Traceback (most recent call last):'
E           and: '  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event'
E           and: "    raise RuntimeError('event processed')"
E           and: 'RuntimeError: event processed'
E           and: '________________________________________________________________________________'
E           and: '----------------------------- Captured stderr call -----------------------------'
E           and: 'Exceptions caught in Qt event loop:'
E           and: '________________________________________________________________________________'
E           and: 'Traceback (most recent call last):'
E           and: '  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event'
E           and: "    raise RuntimeError('event processed')"
E           and: 'RuntimeError: event processed'
E           and: '________________________________________________________________________________'
E           and: 'Exceptions caught in Qt event loop:'
E           and: '________________________________________________________________________________'
E           and: 'Traceback (most recent call last):'
E           and: '  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event'
E           and: "    raise RuntimeError('event processed')"
E           and: 'RuntimeError: event processed'
E           and: '________________________________________________________________________________'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_exceptions_dont_leak.py::test_2 - assert []'
E           and: 'FAILED test_exceptions_dont_leak.py::test_1'
E           and: '============================== 2 failed in 0.04s ==============================='
E       remains unmatched: '*1 failed, 1 passed*'

/disk-samsung/freebsd-ports/devel/py-pytest-qt/work-py39/pytest-qt-4.1.0/tests/test_exceptions.py:381: Failed
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform freebsd13 -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0
PyQt5 5.15.6 -- Qt runtime 5.15.5 -- Qt compiled 5.15.5
Using --randomly-seed=3508469783
rootdir: /tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0
plugins: qt-4.1.0, forked-1.4.0, hypothesis-6.55.0, cov-2.9.0, rerunfailures-10.1, xdist-2.5.0, randomly-3.12.0, typeguard-2.13.3
collected 2 items

test_exceptions_dont_leak.py FF                                          [100%]

=================================== FAILURES ===================================
____________________________________ test_2 ____________________________________

qapp = <PyQt5.QtWidgets.QApplication object at 0x8fc7e2430>

    def test_2(qapp):
>       assert called
E       assert []

test_exceptions_dont_leak.py:22: AssertionError
____________________________________ test_1 ____________________________________
CALL ERROR: Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event
    raise RuntimeError('event processed')
RuntimeError: event processed
________________________________________________________________________________
Traceback (most recent call last):
  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event
    raise RuntimeError('event processed')
RuntimeError: event processed
________________________________________________________________________________
----------------------------- Captured stderr call -----------------------------
Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event
    raise RuntimeError('event processed')
RuntimeError: event processed
________________________________________________________________________________
Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/tmp/pytest-of-yuri/pytest-0/test_exceptions_dont_leak0/test_exceptions_dont_leak.py", line 9, in event
    raise RuntimeError('event processed')
RuntimeError: event processed
________________________________________________________________________________
=========================== short test summary info ============================
FAILED test_exceptions_dont_leak.py::test_2 - assert []
FAILED test_exceptions_dont_leak.py::test_1
============================== 2 failed in 0.04s ===============================
_______________________________________________________________________________ test_qt_api_ini_config[pyqt5] ________________________________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-yuri/pytest-0/test_qt_api_ini_config3')>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x902e88520>, option_api = 'pyqt5'

    @pytest.mark.parametrize("option_api", ["pyqt5", "pyqt6", "pyside2", "pyside6"])
    def test_qt_api_ini_config(testdir, monkeypatch, option_api):
        """
        Test qt_api ini option handling.
        """
        from pytestqt.qt_compat import qt_api
    
        monkeypatch.delenv("PYTEST_QT_API", raising=False)
    
        testdir.makeini(
            """
            [pytest]
            qt_api={option_api}
        """.format(
                option_api=option_api
            )
        )
    
        testdir.makepyfile(
            """
            import pytest
    
            def test_foo(qtbot):
                pass
        """
        )
    
        result = testdir.runpytest_subprocess()
        if qt_api.pytest_qt_api == option_api:
            result.stdout.fnmatch_lines(["* 1 passed in *"])
        else:
            try:
                ModuleNotFoundError
            except NameError:
                # Python < 3.6
                result.stderr.fnmatch_lines(["*ImportError:*"])
            else:
                # Python >= 3.6
>               result.stderr.fnmatch_lines(["*ModuleNotFoundError:*"])
E               Failed: remains unmatched: '*ModuleNotFoundError:*'

/disk-samsung/freebsd-ports/devel/py-pytest-qt/work-py39/pytest-qt-4.1.0/tests/test_basics.py:480: Failed
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
running: /usr/local/bin/python3.9 -mpytest --basetemp=/tmp/pytest-of-yuri/pytest-0/test_qt_api_ini_config3/runpytest-0
     in: /tmp/pytest-of-yuri/pytest-0/test_qt_api_ini_config3
============================= test session starts ==============================
platform freebsd13 -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0
PyQt5 5.15.6 -- Qt runtime 5.15.5 -- Qt compiled 5.15.5
Using --randomly-seed=655155166
rootdir: /tmp/pytest-of-yuri/pytest-0/test_qt_api_ini_config3, configfile: tox.ini
plugins: qt-4.1.0, forked-1.4.0, hypothesis-6.55.0, cov-2.9.0, rerunfailures-10.1, xdist-2.5.0, randomly-3.12.0, typeguard-2.13.3
collected 1 item

test_qt_api_ini_config.py .                                              [100%]

============================== 1 passed in 0.08s ===============================
================================================================================== short test summary info ===================================================================================
SKIPPED [1] tests/test_wait_signal.py:922: test only makes sense for PySide2, whose signals don't contain a name!
SKIPPED [1] tests/test_wait_signal.py:1206: test only makes sense for PySide, whose signals don't contain a name!
========================================================================= 3 failed, 371 passed, 2 skipped in 55.32s ==========================================================================
*** Error code 1

Version: 4.1.0
Python-3.9
FreeBSD 13.1 STABLE

@The-Compiler
Copy link
Member

Could you please try without other pytest plugins installed?

@yurivict
Copy link
Author

For version 4.4.0 running with py311-qt6-pyqt-6.7.1 there are still 3 test failures:

==================================================================================== test session starts ====================================================================================
platform freebsd14 -- Python 3.11.10, pytest-8.1.1, pluggy-1.5.0
PyQt6 6.7.1 -- Qt runtime 6.7.3 -- Qt compiled 6.7.3
rootdir: /usr/ports/devel/py-pytest-qt/work-py311/pytest-qt-4.4.0
configfile: pytest.ini
plugins: qt-4.4.0
collected 381 items                                                                                                                                                                         

test_basics.py ..............................F...F.............                                                                                                                       [ 12%]
test_exceptions.py ...............                                                                                                                                                    [ 16%]
test_logging.py ................................                                                                                                                                      [ 24%]
test_modeltest.py ................................                                                                                                                                    [ 33%]
test_qtbot_pep8_aliases.py ...........                                                                                                                                                [ 36%]
test_qtest_proxies.py ..............                                                                                                                                                  [ 39%]
test_screenshot.py .F...........                                                                                                                                                      [ 43%]
test_wait_signal.py ................................................................................................................................................................. [ 85%]
................s...............s................                                                                                                                                     [ 98%]
test_wait_until.py ......                                                                                                                                                             [100%]

========================================================================================= FAILURES ==========================================================================================
_______________________________________________________________________________ test_qt_api_ini_config[pyqt5] _______________________________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config0')>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x216f43924bd0>, option_api = 'pyqt5'

    @pytest.mark.parametrize("option_api", ["pyqt5", "pyqt6", "pyside2", "pyside6"])
    def test_qt_api_ini_config(testdir, monkeypatch, option_api):
        """
        Test qt_api ini option handling.
        """
        from pytestqt.qt_compat import qt_api
    
        monkeypatch.delenv("PYTEST_QT_API", raising=False)
    
        testdir.makeini(
            """
            [pytest]
            qt_api={option_api}
        """.format(
                option_api=option_api
            )
        )
    
        testdir.makepyfile(
            """
            import pytest
    
            def test_foo(qtbot):
                pass
        """
        )
    
        result = testdir.runpytest_subprocess()
        if qt_api.pytest_qt_api == option_api:
            result.stdout.fnmatch_lines(["* 1 passed in *"])
        else:
            try:
                ModuleNotFoundError
            except NameError:
                # Python < 3.6
                result.stderr.fnmatch_lines(["*ImportError:*"])
            else:
                # Python >= 3.6
>               result.stderr.fnmatch_lines(["*ModuleNotFoundError:*"])
E               Failed: nomatch: '*ModuleNotFoundError:*'
E                   and: 'INTERNALERROR> Traceback (most recent call last):'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 281, in wrap_session'
E                   and: 'INTERNALERROR>     config._do_configure()'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1121, in _do_configure'
E                   and: 'INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 535, in call_historic'
E                   and: 'INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)'
E                   and: 'INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec'
E                   and: 'INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)'
E                   and: 'INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall'
E                   and: 'INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall'
E                   and: 'INTERNALERROR>     res = hook_impl.function(*args)'
E                   and: 'INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/plugin.py", line 243, in pytest_configure'
E                   and: 'INTERNALERROR>     qt_api.set_qt_api(config.getini("qt_api"))'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 108, in set_qt_api'
E                   and: 'INTERNALERROR>     self.QtCore = QtCore = _import_module("QtCore")'
E                   and: 'INTERNALERROR>                            ^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 106, in _import_module'
E                   and: 'INTERNALERROR>     return getattr(m, module_name)'
E                   and: 'INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: "INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'QtCore'"
E               remains unmatched: '*ModuleNotFoundError:*'

/usr/ports/devel/py-pytest-qt/work-py311/pytest-qt-4.4.0/tests/test_basics.py:479: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
running: /usr/local/bin/python3.11 -mpytest --basetemp=/tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config0/runpytest-0
     in: /tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config0
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 281, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1121, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 535, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/plugin.py", line 243, in pytest_configure
INTERNALERROR>     qt_api.set_qt_api(config.getini("qt_api"))
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 108, in set_qt_api
INTERNALERROR>     self.QtCore = QtCore = _import_module("QtCore")
INTERNALERROR>                            ^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 106, in _import_module
INTERNALERROR>     return getattr(m, module_name)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'QtCore'
_________________________________________________________________________ test_qt_api_ini_config_with_envvar[pyqt5] _________________________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config_with_envvar0')>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x216f4394f790>, envvar = 'pyqt5'

    @pytest.mark.parametrize("envvar", ["pyqt5", "pyqt6", "pyside2", "pyside6"])
    def test_qt_api_ini_config_with_envvar(testdir, monkeypatch, envvar):
        """ensure environment variable wins over config value if both are present"""
        testdir.makeini(
            """
            [pytest]
            qt_api={option_api}
        """.format(
                option_api="piecute"
            )
        )
    
        monkeypatch.setenv("PYTEST_QT_API", envvar)
    
        testdir.makepyfile(
            """
            import pytest
    
            def test_foo(qtbot):
                pass
        """
        )
    
        result = testdir.runpytest_subprocess()
        if qt_api.pytest_qt_api == envvar:
            result.stdout.fnmatch_lines(["* 1 passed in *"])
        else:
            try:
                ModuleNotFoundError
            except NameError:
                # Python < 3.6
                result.stderr.fnmatch_lines(["*ImportError:*"])
            else:
                # Python >= 3.6
>               result.stderr.fnmatch_lines(["*ModuleNotFoundError:*"])
E               Failed: nomatch: '*ModuleNotFoundError:*'
E                   and: 'INTERNALERROR> Traceback (most recent call last):'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 281, in wrap_session'
E                   and: 'INTERNALERROR>     config._do_configure()'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1121, in _do_configure'
E                   and: 'INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 535, in call_historic'
E                   and: 'INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)'
E                   and: 'INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec'
E                   and: 'INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)'
E                   and: 'INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall'
E                   and: 'INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)'
E                   and: 'INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall'
E                   and: 'INTERNALERROR>     res = hook_impl.function(*args)'
E                   and: 'INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/plugin.py", line 243, in pytest_configure'
E                   and: 'INTERNALERROR>     qt_api.set_qt_api(config.getini("qt_api"))'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 108, in set_qt_api'
E                   and: 'INTERNALERROR>     self.QtCore = QtCore = _import_module("QtCore")'
E                   and: 'INTERNALERROR>                            ^^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 106, in _import_module'
E                   and: 'INTERNALERROR>     return getattr(m, module_name)'
E                   and: 'INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: "INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'QtCore'"
E               remains unmatched: '*ModuleNotFoundError:*'

/usr/ports/devel/py-pytest-qt/work-py311/pytest-qt-4.4.0/tests/test_basics.py:516: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
running: /usr/local/bin/python3.11 -mpytest --basetemp=/tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config_with_envvar0/runpytest-0
     in: /tmp/pytest-of-yuri/pytest-180/test_qt_api_ini_config_with_envvar0
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 281, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1121, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 535, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/plugin.py", line 243, in pytest_configure
INTERNALERROR>     qt_api.set_qt_api(config.getini("qt_api"))
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 108, in set_qt_api
INTERNALERROR>     self.QtCore = QtCore = _import_module("QtCore")
INTERNALERROR>                            ^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 106, in _import_module
INTERNALERROR>     return getattr(m, module_name)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'QtCore'
________________________________________________________________________________________ test_region ________________________________________________________________________________________

qtbot = <pytestqt.qtbot.QtBot object at 0x216f43b50850>, widget = <PyQt6.QtWidgets.QWidget object at 0x216f43d8f760>

    def test_region(qtbot, widget):
        region = qt_api.QtCore.QRect(0, 0, 25, 25)
        path = qtbot.screenshot(widget, region=region)
    
        pixmap = qt_api.QtGui.QPixmap()
        assert pixmap.load(str(path))
>       assert pixmap.rect() == region
E       assert PyQt6.QtCore.QRect(0, 0, 42, 42) == PyQt6.QtCore.QRect(0, 0, 25, 25)
E        +  where PyQt6.QtCore.QRect(0, 0, 42, 42) = <built-in method rect of QPixmap object at 0x216f43c253f0>()
E        +    where <built-in method rect of QPixmap object at 0x216f43c253f0> = <PyQt6.QtGui.QPixmap object at 0x216f43c253f0>.rect

test_screenshot.py:35: AssertionError
================================================================================== short test summary info ==================================================================================
FAILED test_basics.py::test_qt_api_ini_config[pyqt5] - Failed: nomatch: '*ModuleNotFoundError:*'
FAILED test_basics.py::test_qt_api_ini_config_with_envvar[pyqt5] - Failed: nomatch: '*ModuleNotFoundError:*'
FAILED test_screenshot.py::test_region - assert PyQt6.QtCore.QRect(0, 0, 42, 42) == PyQt6.QtCore.QRect(0, 0, 25, 25)
========================================================================= 3 failed, 376 passed, 2 skipped in 46.88s =========================================================================
*** Error code 1

No other PyTest plugins are installed.

Python-3.11
FreeBSD 14.1

@nicoddemus
Copy link
Member

From this failure:

E                   and: 'INTERNALERROR>   File "/usr/ports/devel/py-pytest-qt/work-py311/stage/usr/local/lib/python3.11/site-packages/pytestqt/qt_compat.py", line 106, in _import_module'
E                   and: 'INTERNALERROR>     return getattr(m, module_name)'
E                   and: 'INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^'
E                   and: "INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'QtCore'"
E               remains unmatched: '*ModuleNotFoundError:*'

It seems like PyQt5 can be imported, but not PyQt5.QtCore, which is unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants