simple example does not seem to work
See original GitHub issueI cannot get the simplest example to work. It is probably me not understanding what to import.
I get E ModuleNotFoundError: No module named 'pytestqt'
.
Here’s the steps I did:
- created a python virtual environment: python3 -m venv venv
- activated the environment: source venv/bin/activate
- pip install PySide6 pytest pytest-qt
- created a test_hello.py (copied from doc)
from pytestqt import qtbot
def test_hello(qtbot):
widget = HelloWidget()
qtbot.addWidget(widget)
# click in the Greet button and make sure it updates the appropriate label
qtbot.mouseClick(widget.button_greet, qt_api.QtCore.Qt.MouseButton.LeftButton)
assert widget.greet_label.text() == "Hello!"
- Run pytest: pytest
I expect a green pytest 1/1 success.
Instead I get this error:
% pytest
================================================================ test session starts =================================================================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /nix/code/pytest-qt-example
plugins: cov-3.0.0
collected 0 items / 1 error
======================================================================= ERRORS =======================================================================
___________________________________________________________ ERROR collecting test_hello.py ___________________________________________________________
ImportError while importing test module '/nix/code/pytest-qt-example/test_hello.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_hello.py:1: in <module>
from pytestqt import qtbot
E ModuleNotFoundError: No module named 'pytestqt'
============================================================== short test summary info ===============================================================
ERROR test_hello.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================== 1 error in 0.08s ==================================================================
I created a simple repo, if you just want to clone it and validate: https://github.com/mkinney/pytest-qt-example
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
The best 500 seem sentence examples - YourDictionary
The most voted sentence example for seem is You never seem to study.... ... but crystals are small and usually indistinct; there is...
Read more >Computer Basics: Basic Troubleshooting Techniques
Whenever you have a problem with your computer, don't panic! There are many basic troubleshooting techniques you can use to fix issues like...
Read more >GTK3 Drawing area tutorial does not seem to exist?
1 Answer 1 ... You basically connect to the ::draw signal and draw in the handler using pycairo. And use queue_draw/queue_draw_area() if you...
Read more >Logic and Mathematical Statements - Worked Examples
For this statement to be false, you can't be rich and you can't been happy. In other words, the opposite is to be...
Read more >Non sequitur Definition & Meaning - Merriam-Webster
In Latin, non sequitur means "it does not follow." The phrase was borrowed into English in the 1500s by people who made a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got it working.
https://github.com/mkinney/pytest-qt-example
Closing for now, feel free to follow up with further questions.