From 2313b8ba65da2c637a45248e000ecc802b58c56e Mon Sep 17 00:00:00 2001 From: oakkitten Date: Wed, 30 Mar 2022 20:20:40 +0100 Subject: [PATCH] Add `tox.ini`, remove `test.sh` The tests can be run now using `tox` against multiple Anki versions; see instructions in `tox.ini`. The tests depend on `pytest-anki` that had to be slightly modified to remove the upper constraint on Anki version, as well as to remove a few dependencies that are not essential to using it. --- test.sh | 2 -- tox.ini | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) delete mode 100755 test.sh create mode 100644 tox.ini diff --git a/test.sh b/test.sh deleted file mode 100755 index 61a4948..0000000 --- a/test.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/bash -python -m unittest discover -v tests diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..96e56f5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,76 @@ +# For testing, you will need: +# * PyQt5 dev tools +# * tox +# * X virtual framebuffer--to test without GUI +# +# Install these by running: +# $ sudo apt install pyqt5-dev-tools xvfb +# $ python3 -m pip install --user --upgrade tox +# +# Then, to run tests against multiple anki versions: +# $ tox +# +# To run tests slightly less safely, but faster: +# $ tox -- --no-tear-down-profile-after-each-test +# +# To run tests more safely, but *much* slower: +# $ tox -- --forked + +# Test tool cheat sheet: +# * Test several environments in parallel: +# $ tox -p auto +# +# * To activate one of the test environments: +# $ source .tox/py38-anki49/bin/activate +# +# * Stop on first failure: +# $ xvfb-run python -m pytest -x +# +# * See stdout/stderr (doesn't work with --forked!): +# $ xvfb-run python -m pytest -s +# +# * Run some specific tests: +# $ xvfb-run python -m pytest -k "test_cards.py or test_guiBrowse" +# +# * To run with visible GUI in WSL2 +# (Make sure to disable access control in your X server, such as VcXsrv): +# $ DISPLAY=$(ip route list default | awk '{print $3}'):0 python -m pytest +# +# * Environmental variables of interest: +# LIBGL_ALWAYS_INDIRECT=1 +# QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" +# QT_DEBUG_PLUGINS=1 +# ANKIDEV=true + +[tox] +minversion = 3.24 +skipsdist = true +skip_install = true +envlist = py38-anki{45,46,47,48,49} + +[testenv] +commands = + xvfb-run python -m pytest {posargs} +setenv = + HOME={envdir}/home +allowlist_externals = + xvfb-run +deps = + pytest==7.1.1 + pytest-forked==1.4.0 + pytest-anki @ git+https://github.com/oakkitten/pytest-anki.git@17d19043 + + anki45: anki==2.1.45 + anki45: aqt==2.1.45 + + anki46: anki==2.1.46 + anki46: aqt==2.1.46 + + anki47: anki==2.1.47 + anki47: aqt==2.1.47 + + anki48: anki==2.1.48 + anki48: aqt==2.1.48 + + anki49: anki==2.1.49 + anki49: aqt==2.1.49 \ No newline at end of file