#4902 Few more changes related to pytest
Merged 3 years ago by pingou. Opened 3 years ago by pingou.

@@ -9,7 +9,7 @@ 

  * 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:

  

file modified
+3 -3
@@ -14,14 +14,14 @@ 

      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 @@ 

      python3 setup.py build

  

  WORKDIR /pagure

- ENTRYPOINT ["/pagure/dev/containers/runtests_py3.sh"]

+ ENTRYPOINT ["pytest-3 -n auto /pagure/tests/"]

  CMD []

file modified
+5 -5
@@ -13,14 +13,14 @@ 

    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.

file modified
+9 -16
@@ -281,20 +281,19 @@ 

  

  * 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 @@ 

  

            ::

  

-             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.