Closed schmiedc closed 2 years ago
Thanks for the issue and sorry about that @schmiedc...
I opened https://github.com/napari/cookiecutter-napari-plugin/pull/106 to fix this for future cookiecutter users.
To run tests with pytest locally you'll need to have a couple more dependencies installed. run pip install pytest-qt
then try again. If that doesn't do it, let me know
I just experienced the same problem, qtbot is missing when running tests! (with the latest version of the template). Why is pytest-qt not in the testing requirements?
I just experienced the same problem, qtbot is missing when running tests! (with the latest version of the template). Why is pytest-qt not in the testing requirements?
It is ... but only if you said "yes" to "include widget plugin": https://github.com/napari/cookiecutter-napari-plugin/blob/96891d3348d2744dbfd38fb0b140914597fec094/%7B%7Bcookiecutter.plugin_name%7D%7D/setup.cfg#L80
otherwise... there's no immediate need for it, and if you later add a widget manually, then you'll have to add it. (not all plugins need qt, and it's a big thing to add if the plugin isn't using it)
Oh I see, thanks for the explanation!
I played around with testing and went from what was present in the cookiecutter as an example to test widgets. But noticed that I get errors. When applying pytest on a freshly setup cookiecutter I get the following errors:
`pytest . ==================================== test session starts ===================================== platform linux -- Python 3.9.10, pytest-7.1.0, pluggy-1.0.0 rootdir: /home/christopher.schmied/HT_Docs/Projects/2022-03_Hackaton/cookie_cutter/test_cookie/src/test_cookie/_tests plugins: napari-plugin-engine-0.2.0, napari-0.4.15, cov-3.0.0 collected 8 items
test_dock_widget.py EE [ 25%] test_reader.py .. [ 50%] test_sample_data.py . [ 62%] test_widget.py EE [ 87%] test_writer.py . [100%]
=========================================== ERRORS =========================================== __ ERROR at setup of test_example_q_widget ___ file /home/christopher.schmied/HT_Docs/Projects/2022-03_Hackaton/cookie_cutter/test_cookie/src/test_cookie/_tests/test_dock_widget.py, line 6 def test_example_q_widget(make_napari_viewer, capsys): file /home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py, line 103 @pytest.fixture def make_napari_viewer( E fixture 'qtbot' not found
/home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py:103 ____ ERROR at setup of test_example_magicwidget ____ file /home/christopher.schmied/HT_Docs/Projects/2022-03_Hackaton/cookie_cutter/test_cookie/src/test_cookie/_tests/test_dock_widget.py, line 21 def test_example_magic_widget(make_napari_viewer, capsys): file /home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py, line 103 @pytest.fixture def make_napari_viewer( E fixture 'qtbot' not found
/home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py:103 __ ERROR at setup of test_example_q_widget ___ file /home/christopher.schmied/HT_Docs/Projects/2022-03_Hackaton/cookie_cutter/test_cookie/src/test_cookie/_tests/test_widget.py, line 6 def test_example_q_widget(make_napari_viewer, capsys): file /home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py, line 103 @pytest.fixture def make_napari_viewer( E fixture 'qtbot' not found
/home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py:103 ____ ERROR at setup of test_example_magicwidget ____ file /home/christopher.schmied/HT_Docs/Projects/2022-03_Hackaton/cookie_cutter/test_cookie/src/test_cookie/_tests/test_widget.py, line 21 def test_example_magic_widget(make_napari_viewer, capsys): file /home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py, line 103 @pytest.fixture def make_napari_viewer( E fixture 'qtbot' not found
/home/christopher.schmied/.conda/envs/napari-env/lib/python3.9/site-packages/napari/utils/_testsupport.py:103 ================================== short test summary info =================================== ERROR test_dock_widget.py::test_example_q_widget ERROR test_dock_widget.py::test_example_magic_widget ERROR test_widget.py::test_example_q_widget ERROR test_widget.py::test_example_magic_widget ================================ 4 passed, 4 errors in 0.09s =================================`