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

Investigate exceptions with pytest-qt #327

Open
JamesWrigley opened this issue Dec 10, 2021 · 0 comments
Open

Investigate exceptions with pytest-qt #327

JamesWrigley opened this issue Dec 10, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@JamesWrigley
Copy link
Member

Found a weird bug while running the tests with pytest-qt installed:

(extra_foam) ➜  EXtra-foam git:(pytest) python3 -m pytest extra_foam -k foo -s
============================================================================================================= test session starts =============================================================================================================
platform linux -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/james/.conda/envs/extra_foam/bin/python3
cachedir: .pytest_cache
PyQt5 5.13.2 -- Qt runtime 5.13.2 -- Qt compiled 5.13.2
rootdir: /home/james/git/EXtra-foam, configfile: pytest.ini
plugins: qt-4.0.2
collected 614 items / 613 deselected / 1 selected

extra_foam/gui/image_tool/tests/test_image_tool.py::TestImageTool::testFoo libpng warning: iCCP: known incorrect sRGB profile
Foo
tearDown()
PASSEDtearDownClass()
Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 550, in connect
    sock = self._connect()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 606, in _connect
    raise err
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 594, in _connect
    sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/james/git/EXtra-foam/extra_foam/gui/ctrl_widgets/data_source_widget.py", line 841, in updateAvailableSources
    ret = self._mon.get_available_sources()
  File "/home/james/git/EXtra-foam/extra_foam/database/mondata.py", line 145, in get_available_sources
    ret = pipe.execute()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/client.py", line 4006, in execute
    conn = self.connection_pool.get_connection('MULTI',
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 1183, in get_connection
    connection.connect()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 554, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
________________________________________________________________________________
Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/home/james/git/EXtra-foam/extra_foam/gui/image_tool/bulletin_view.py", line 115, in _updateProcessCount
    tid, n_processed, n_dropped, n_processed_pulses = \
TypeError: cannot unpack non-iterable NoneType object
________________________________________________________________________________

extra_foam/gui/image_tool/tests/test_image_tool.py::TestImageTool::testFoo ERROR

=================================================================================================================== ERRORS ====================================================================================================================
_________________________________________________________________________________________________ ERROR at teardown of TestImageTool.testFoo __________________________________________________________________________________________________
TEARDOWN ERROR: Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 550, in connect
    sock = self._connect()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 606, in _connect
    raise err
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 594, in _connect
    sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/james/git/EXtra-foam/extra_foam/gui/ctrl_widgets/data_source_widget.py", line 841, in updateAvailableSources
    ret = self._mon.get_available_sources()
  File "/home/james/git/EXtra-foam/extra_foam/database/mondata.py", line 145, in get_available_sources
    ret = pipe.execute()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/client.py", line 4006, in execute
    conn = self.connection_pool.get_connection('MULTI',
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 1183, in get_connection
    connection.connect()
  File "/home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py", line 554, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
________________________________________________________________________________
Traceback (most recent call last):
  File "/home/james/git/EXtra-foam/extra_foam/gui/image_tool/bulletin_view.py", line 115, in _updateProcessCount
    tid, n_processed, n_dropped, n_processed_pulses = \
TypeError: cannot unpack non-iterable NoneType object
________________________________________________________________________________
============================================================================================================== warnings summary ===============================================================================================================
../../.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py:2
  /home/james/.conda/envs/extra_foam/lib/python3.10/site-packages/redis/connection.py:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternati
ves
    from distutils.version import StrictVersion

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================================================================================================== short test summary info ===========================================================================================================
ERROR extra_foam/gui/image_tool/tests/test_image_tool.py::TestImageTool::testFoo
============================================================================================ 1 passed, 613 deselected, 1 warning, 1 error in 5.79s ============================================================================================

This occurred with a dummy test that does literally nothing, it's just a pass statement. And it only happens with pytest-qt installed. I looked into it briefly, and what I suspect is happening is that there's a timer running that calls a function that calls Redis, and the timer doesn't stop before Redis is shutdown. This specific error is (probably) caused by self._avail_src_timer in DataSourceWidget, but there are similar timers elsewhere like in BulletinView.

It's interesting that this only happens with the pytest-qt plugin, maybe it does some extra introspection for Qt that's missed by pytest?

@JamesWrigley JamesWrigley added the bug Something isn't working label Dec 10, 2021
@JamesWrigley JamesWrigley self-assigned this Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant