diff options
author | Erik Skultety <eskultet@redhat.com> | 2023-03-31 12:42:49 +0200 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2023-04-28 10:05:23 +0000 |
commit | 5cb7702fa4073a0205cb69cbf3f3d3ca8966a60c (patch) | |
tree | 02310cd2464e4018cbf7cf4103ec1141d5759e8e /docs | |
parent | aa49b92c9f4a37762ad0070362007bc030ba0f21 (diff) | |
download | libvirt-ci-5cb7702fa4073a0205cb69cbf3f3d3ca8966a60c.zip libvirt-ci-5cb7702fa4073a0205cb69cbf3f3d3ca8966a60c.tar.gz libvirt-ci-5cb7702fa4073a0205cb69cbf3f3d3ca8966a60c.tar.bz2 |
docs: testing: Update contents with tox
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/testing.rst | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/docs/testing.rst b/docs/testing.rst index 425dce6..c990683 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -2,17 +2,71 @@ Testing ======= -This project utilizes the pytest framework. Make sure you add a new test case -with any new logic you introduce to the lcitool code base. -Whenever you add new package mappings the test suite will naturally fail -because it simply doesn't know about them. In that case, just re-run the test -suite as +Running tests +------------- +This project utilizes the pytest framework. You can either run it directly +yourself or make use of the power of tox and test in different environments. + +Pytest +~~~~~~ + +You can run a smoke check of your changes quickly with + +:: + + $ pytest + +For more extensive checking in different environments please consider using +tox, see below. + +Tox +~~~ +Make sure you have tox installed for this one. You can either install it +manually or via ``dev-requirements.txt`` which will also install all +dependencies for overall lcitool development. Once installed, simply run + +:: + + $ tox + +Running specific test environments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +We define a couple of test environments for tox: + +* ``lint`` flake8 linter +* ``py38`` which reflects our minimum requirement for Python 3.8 +* ``py311`` which is supposed to catch early deprecations with latest Python + +You can select which test environment tox should execute with + +:: + + $ tox -e <test_env> + + +Adding test cases +----------------- +Make sure you add a new test case with any new logic you introduce to the +lcitool code base. Note that whenever you add new package mappings the test +suite will naturally fail because it simply doesn't know about them. In that +case, just re-run the test suite as + +:: + + $ pytest --regenerate-output + +or :: - $ python3 -m pytest --regenerate-output + $ tox -e py38 -- --regenerate-output -and the expected package data sets will be updated. You can then just grab the -changes and add them to your commit. Beware though that if you test a buggy -code this way the tests would not be able to catch regressions since the -"correct" test output would now match the flawed output. +depending on what tool you prefer for testing and the expected package data +sets will be updated automatically. You can then just grab the changes and add +them to your commit. Beware though that if you test a buggy code this way the +tests would not be able to catch regressions since the "correct" test output +would now match the flawed output. Note however that when regenerating output +with ``tox`` you **must** select a test environment with ``tox`` because +otherwise all environments will get the ``--regenerate-output`` option which +could make some of them fail. |