napari / napari-console

A plugin that adds a console to napari
BSD 3-Clause "New" or "Revised" License
3 stars 12 forks source link

Fix tests #7

Closed sofroniewn closed 3 years ago

sofroniewn commented 3 years ago

This will close #3. I had to add the backend stuff for qt, and an optional testing dependency of napari. I also had to copy over a bunch of the napari conftest.py

We might want to ask the cookiecutter - are you a "Qt" plugin and then copy more of this stuff for them.

Not sure if this will pass or not on CI, but maybe @tlambert03 can take a look at this too!

sofroniewn commented 3 years ago

I also took the latest 3.9 workflows from the cookiecutter

sofroniewn commented 3 years ago

looks like it's still not getting pyside2 ...

tlambert03 commented 3 years ago

I also had to copy over a bunch of the napari conftest.py

I think the "proper" fix here is to make napari a legitimate pytest plugin, by adding a pytest11 entrypoint, (similar to how napari-plugin-engine also provides fixtures). For instance, if you add this to napari's setup.cfg entry_points:

[options.entry_points]
console_scripts =
    napari = napari.__main__:main
pytest11 =
    napari = napari.conftest

(and do pip install -e . again in your napari directory), then you should be able to use make_test_viewer in napari_console without copying over conftest.py.

If you like that idea, then I think we'd want to move that stuff out of conftest (which I think is really intended just for the package it is declared in), and into something like napari._testsupport... and that's what we would export. Let me know if you try that out and run into issues.

looks like it's still not getting pyside2 ...

see the note in the tox.ini of napari where you copied the [gh-actions:env] entry from:

# This section turns environment variables from github actions
# into tox environment factors. This, combined with the [gh-actions]
# section above would mean that a test running python 3.9 on ubuntu-latest
# with an environment variable of BACKEND=pyqt would be converted to a
# tox env of `py39-linux-pyqt5`

you're lacking an BACKEND: ${{ matrix.backend }} environment variable in your github actions, so tox doesn't do anything with that [gh-actions:env] entry. However, to simplify things, just remove backend all together and it will test {pyqt,pyside} on all platforms.

Further, you've put the pyqt/pyside entries in the "extras" section:

extras =
    napari
    pyqt: pyqt5
    pyside: pyside2

but this package doesn't declare any extras... so tox again does nothing with that. You need to use the deps section (not extras)

Moreover, for this package, unlike napari, I don't think you should add extras. Since this package will only ever be used with napari, just leave it up to whatever extra the user used in napari,

deps = 
    pytest
    pytest-cov
    pytest-xvfb ; sys_platform == 'linux'
    pyqt: napari[pyqt5,testing]
    pyside: napari[pyside2,testing]

I can push to this PR if you like, but I do think it's important to understand what's going on here too

codecov-io commented 3 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@2574e02). Click here to learn what that means. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #7   +/-   ##
=======================================
  Coverage        ?   83.18%           
=======================================
  Files           ?        3           
  Lines           ?      113           
  Branches        ?        0           
=======================================
  Hits            ?       94           
  Misses          ?       19           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2574e02...e4d4f07. Read the comment docs.

sofroniewn commented 3 years ago

@tlambert03 thanks for the detailed advice! I'm much closed now, just struggling with numcodes and python 3.9 on macOS. I added a conda-dep like we have in the main repo, but don't think I have it quite right.

It's also a little unclear to me what's happened with the different backends now. Are these getting tested "sequentially" in the same test now like in the main repo?

sofroniewn commented 3 years ago

Tests all passing now! Will merge :-)