Browse Source

Doc pytest plugin (#6289)

* update to new pytest name

* doc pytest plugin

* trim heading to the length of the new pytest name
pull/6338/head
Thomas Grainger 2 years ago committed by GitHub
parent
commit
4296611f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      CONTRIBUTING.rst
  2. 2
      Makefile
  3. 2
      celery/contrib/pytest.py
  4. 2
      docker/Dockerfile
  5. 15
      docs/userguide/testing.rst
  6. 2
      setup.py
  7. 2
      t/unit/app/test_schedules.py

20
CONTRIBUTING.rst

@ -592,14 +592,14 @@ To run the Celery test suite you need to install
$ pip install -U -r requirements/default.txt
After installing the dependencies required, you can now execute
the test suite by calling :pypi:`py.test <pytest>`:
the test suite by calling :pypi:`pytest <pytest>`:
.. code-block:: console
$ py.test t/unit
$ py.test t/integration
$ pytest t/unit
$ pytest t/integration
Some useful options to :command:`py.test` are:
Some useful options to :command:`pytest` are:
* ``-x``
@ -618,7 +618,7 @@ you can do so like this:
.. code-block:: console
$ py.test t/unit/worker/test_worker.py
$ pytest t/unit/worker/test_worker.py
.. _contributing-coverage:
@ -636,11 +636,11 @@ Installing the :pypi:`pytest-cov` module:
Code coverage in HTML format
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#. Run :command:`py.test` with the ``--cov-report=html`` argument enabled:
#. Run :command:`pytest` with the ``--cov-report=html`` argument enabled:
.. code-block:: console
$ py.test --cov=celery --cov-report=html
$ pytest --cov=celery --cov-report=html
#. The coverage output will then be located in the :file:`htmlcov/` directory:
@ -651,11 +651,11 @@ Code coverage in HTML format
Code coverage in XML (Cobertura-style)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#. Run :command:`py.test` with the ``--cov-report=xml`` argument enabled:
#. Run :command:`pytest` with the ``--cov-report=xml`` argument enabled:
.. code-block:: console
$ py.test --cov=celery --cov-report=xml
$ pytest --cov=celery --cov-report=xml
#. The coverage XML output will then be located in the :file:`coverage.xml` file.
@ -828,7 +828,7 @@ make it easier for the maintainers to accept your proposed changes:
``Needs Test Coverage``.
- [ ] Make sure unit test coverage does not decrease.
``py.test -xv --cov=celery --cov-report=xml --cov-report term``.
``pytest -xv --cov=celery --cov-report=xml --cov-report term``.
You can check the current test coverage here: https://codecov.io/gh/celery/celery
- [ ] Run ``flake8`` against the code. The following commands are valid

2
Makefile

@ -1,7 +1,7 @@
PROJ=celery
PGPIDENT="Celery Security Team"
PYTHON=python
PYTEST=py.test
PYTEST=pytest
GIT=git
TOX=tox
ICONV=iconv

2
celery/contrib/pytest.py

@ -1,4 +1,4 @@
"""Fixtures and testing utilities for :pypi:`py.test <pytest>`."""
"""Fixtures and testing utilities for :pypi:`pytest <pytest>`."""
import os
from contextlib import contextmanager

2
docker/Dockerfile

@ -114,5 +114,5 @@ WORKDIR $HOME/celery
# Setup the entrypoint, this ensures pyenv is initialized when a container is started
# and that any compiled files from earlier steps or from mounts are removed to avoid
# py.test failing with an ImportMismatchError
# pytest failing with an ImportMismatchError
ENTRYPOINT ["/entrypoint"]

15
docs/userguide/testing.rst

@ -88,14 +88,23 @@ in this example:
with raises(Retry):
send_order(product.pk, 3, Decimal(30.6))
Py.test
=======
pytest
======
.. versionadded:: 4.0
Celery is also a :pypi:`pytest` plugin that adds fixtures that you can
Celery also makes a :pypi:`pytest` plugin available that adds fixtures that you can
use in your integration (or unit) test suites.
Enabling
--------
Celery initially ships the plugin in a disabled state, to enable it you can either:
* `pip install celery[pytest]`
* `pip install pytest-celery`
* or add `pytest_plugins = 'celery.contrib.pytest'` to your pytest.ini
Marks
-----

2
setup.py

@ -136,7 +136,7 @@ def long_description():
class pytest(setuptools.command.test.test):
user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
user_options = [('pytest-args=', 'a', 'Arguments to pass to pytest')]
def initialize_options(self):
setuptools.command.test.test.initialize_options(self)

2
t/unit/app/test_schedules.py

@ -599,7 +599,7 @@ class test_crontab_is_due:
try:
assertions.assertAlmostEqual(a, b + skew, precision)
except Exception as exc:
# AssertionError != builtins.AssertionError in py.test
# AssertionError != builtins.AssertionError in pytest
if 'AssertionError' in str(exc):
if index + 1 >= 3:
raise

Loading…
Cancel
Save