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

Weird pytest error: 'CompletionHtml' object has no attribute '_text_edit' #582

Open
juliangilbey opened this issue Jun 28, 2023 · 4 comments

Comments

@juliangilbey
Copy link

While building qtconsole for Debian, we run the test suite in a clean environment. And with version 5.4.3, we're now often getting a very strange pytest error (the times at the beginning of the lines are a running clock):

 50s Testing with python3.11:
 50s ============================= test session starts ==============================
 50s platform linux -- Python 3.11.4, pytest-7.2.1, pluggy-1.0.0+repack
 50s PyQt5 5.15.9 -- Qt runtime 5.15.8 -- Qt compiled 5.15.8
 50s rootdir: /tmp/autopkgtest-lxc._jqfs5cq/downtmp/build.peT/src
 50s plugins: flaky-3.7.0, qt-4.2.0+repack
 50s collected 46 items
 50s 
109s qtconsole/tests/test_00_console_widget.py ................               [ 34%]
109s qtconsole/tests/test_ansi_code_processor.py ...........                  [ 58%]
110s qtconsole/tests/test_app.py .s                                           [ 63%]
111s qtconsole/tests/test_comms.py ..                                         [ 67%]
111s qtconsole/tests/test_completion_widget.py ....                           [ 76%]
111s qtconsole/tests/test_frontend_widget.py ..                               [ 80%]
111s qtconsole/tests/test_inprocess_kernel.py .                               [ 82%]
111s qtconsole/tests/test_jupyter_widget.py ...                               [ 89%]
111s qtconsole/tests/test_kill_ring.py ...                                    [ 95%]
111s qtconsole/tests/test_styles.py ..                                        [100%]
111s ===Flaky Test Report===
111s 
111s test_scroll[True] passed 1 out of the required 1 times. Success!
111s test_scroll[False] passed 1 out of the required 1 times. Success!
111s test_input passed 1 out of the required 1 times. Success!
111s test_debug passed 1 out of the required 1 times. Success!
111s test_input_and_print failed (14 runs remaining out of 15).
111s 	<class 'pytestqt.exceptions.TimeoutError'>
111s 	waitUntil timed out in 5000 milliseconds
111s 	[<TracebackEntry /tmp/autopkgtest-lxc._jqfs5cq/downtmp/build.peT/src/qtconsole/tests/test_00_console_widget.py:239>, <TracebackEntry /tmp/autopkgtest-lxc._jqfs5cq/downtmp/build.peT/src/qtconsole/tests/test_00_console_widget.py:223>]
111s test_input_and_print passed 1 out of the required 1 times. Success!
111s test_restart_after_kill passed 1 out of the required 1 times. Success!
111s 
111s ===End Flaky Test Report===
111s 
111s =================== 45 passed, 1 skipped in 60.96s (0:01:00) ===================
111s Traceback (most recent call last):
111s   File "/tmp/autopkgtest-lxc._jqfs5cq/downtmp/build.peT/src/qtconsole/completion_html.py", line 149, in eventFilter
111s     if obj == self._text_edit:
111s               ^^^^^^^^^^^^^^^
111s AttributeError: 'CompletionHtml' object has no attribute '_text_edit'
111s Aborted

It looks like a qtbot.waitUntil timeout (from the TracebackEntry), but then there is the very strange error at the end about the _text_edit attribute being missing.

Do you have any idea what might be causing this or how to fix it?

@juliangilbey
Copy link
Author

I just realised that the qbot.waitUntil timeout is in a flaky report, and is fine. But it is the weird _text_edit issue which is frequently happening, even when the test_input_and_print call is successful first time.

@juliangilbey
Copy link
Author

Update: I have located the source of the issue (though I don't understand why it is breaking); it is the test in qtconsole/tests/test_inprocess_kernel.py which causes the error. Running this test under unittest rather than pytest passes with no issues.

@rayosborn
Copy link
Contributor

Testing is not really my area of expertise, but the tests were set up as unittests so I'm not completely sure why you want to use pytest. In my clone of the repository, test_inprocess_kernel.py gives no error.

@juliangilbey
Copy link
Author

Hi @rayosborn, some of the test files contain only pytest tests, some contain only unittest tests and some contain a mixture. The GitHub workflow runs all the tests using pytest:

- name: Run tests
shell: bash -l {0}
run: xvfb-run --auto-servernum pytest -vv -s --full-trace --color=yes --cov=qtconsole qtconsole
env:
QT_API: ${{ matrix.QT_LIB }}
PYTEST_QT_API: ${{ matrix.QT_LIB }}

But for some strange reason, this caused the error described above on a Debian system.

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

2 participants