From 8538d5c52ce1f4302a04860e9306e5a68566ad3f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 19 2020 20:14:51 +0000 Subject: [PATCH 1/2] Adjust the documentation around running tests Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/files/motd b/dev/ansible/roles/pagure-dev/files/motd index d30f2e1..f68e964 100644 --- a/dev/ansible/roles/pagure-dev/files/motd +++ b/dev/ansible/roles/pagure-dev/files/motd @@ -9,7 +9,7 @@ Here are some tips: * Logs for the server are available with `journalctl`; the services are run as systemd user units in ~/.config/systemd/user/ -* To run the tests run: `~/devel/runtests.py run`. +* To run the tests run: `tox -c ~/devel/tox.ini`. Here is a list of command and alias you may find useful: diff --git a/doc/contributing.rst b/doc/contributing.rst index 370c527..ebb3b08 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -13,14 +13,14 @@ If you're submitting patches to pagure, please observe the following: yourself (which is simple: ``black /path/to/pagure``). - Check that your code doesn't break the test suite. The test suite can be - run using the ``runtests.py`` script at the top of the sources, you may - use ``python runtests.py run`` to run the tests and ``python runtests.py --help`` - to check other options supported. + run using ``tox`` at the top of the sources, you mayuse ``tox . -e py38`` to + run a single version of python. You can also run a single file by calling + pytest directly: ``pytest-3 tests/test_style.py``. See :doc:`development` for more information about the test suite. - If you are adding new code, please write tests for them in ``tests/``, - the ``runtests.py`` script will help you to see the coverage of your code - in unit-tests. + ``tox .`` will run the tests and show you the coverage of the code by the + unit-tests. - If your change warrants a modification to the docs in ``doc/`` or any docstrings in ``pagure/`` please make that modification. diff --git a/doc/development.rst b/doc/development.rst index 5ed3d8d..4ca3729 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -281,20 +281,19 @@ local pagure instance. * Run it:: - python runtests.py run + tox . -You can also use:: +If you want to run a single interpreter, cou can use:: - python runtests.py --help + tox . -e py38 -to see other options supported. Each unit-tests files (located under ``tests/``) can be called by alone, allowing easier debugging of the tests. For example: :: - python runtests.py run tests/test_pagure_lib.py + pytest-3 tests/test_pagure_lib.py .. note:: In order to have coverage information you might have to install @@ -302,22 +301,16 @@ by alone, allowing easier debugging of the tests. For example: :: - dnf install python-coverage + dnf install python3-pytest-cov - or - - :: - - yum install python-coverage To run the unit-tests, there is also a container available with all the dependencies needed. Use the following command to run the tests :: $ ./dev/run-tests-container.py -This command will build a fedora based container and execute the test suite. You can also -limit the tests to unit-test files or single tests similar to the ``python runtests.py`` -options described above. You need set the environment variables REPO and BRANCH if the -tests are not yet available in the upstream pagure master branch. - +This command will build a fedora based container and execute the test suite. +You can also limit the tests to unit-test files or single tests similar to the +options described above. You need set the environment variables REPO and BRANCH +if the tests are not yet available in the upstream pagure master branch. From 7007bccb37d69c446a8d44e3c35e15e41afe793c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 21 2020 19:54:07 +0000 Subject: [PATCH 2/2] Make the rpm/py3 container call pytest directly Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/containers/f31-rpms-py3 b/dev/containers/f31-rpms-py3 index 7cf977f..6491171 100644 --- a/dev/containers/f31-rpms-py3 +++ b/dev/containers/f31-rpms-py3 @@ -14,14 +14,14 @@ RUN dnf -y --enablerepo=updates-testing install \ python3-docutils \ python3-black \ python3-flake8 \ + python3-pytest-xdist \ redis \ which \ git RUN cd / \ && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b $BRANCH $REPO \ - && chmod +x /pagure/dev/containers/runtests_py3.sh \ - && sed -i -e 's|\["alembic",|\["alembic-3",|' /pagure/tests/test_alembic.py + && chmod +x /pagure/dev/containers/runtests_py3.sh # Install all the requirements from the spec file and replace the macro # %{python_pkgversion} by '3' which thus installs all the py3 version of @@ -35,5 +35,5 @@ RUN sed -i "/Requires: python%{python_pkgversion}-enum34/d" /pagure/fi python3 setup.py build WORKDIR /pagure -ENTRYPOINT ["/pagure/dev/containers/runtests_py3.sh"] +ENTRYPOINT ["pytest-3 -n auto /pagure/tests/"] CMD []