Skip to content

Commit

Permalink
Don’t use pytest plugins by default
Browse files Browse the repository at this point in the history
Sometimes, when a new version of pytest, flake8 or isort is released, we get
new problems. Sometimes the bug is quickly fixed, sometimes it ends in drama
(I’m looking at you, tholo/pytest-flake8#87).

Pytest, flake8 and isort are robust tools, and we’d like to continue to use
them and to install them as testing dependencies.

Let’s lauch the tools without Pytest. We keep their configuration in
pyproject.toml so that users who want to use them in their editors can benefit
from the default tweaks. We remove the default pytest options so that packagers
don’t have to edit or remove pyproject.toml, and only have to install
pytest (linting is useless for packaging). We install pytest-xdist to launch
our tests in parallel for the CI.
  • Loading branch information
liZe committed Sep 6, 2022
1 parent ab7581c commit b9c086d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
- name: Upgrade pip and setuptools
run: python -m pip install --upgrade pip setuptools
- name: Install tests’ requirements
run: python -m pip install .[test]
run: python -m pip install .[test] pytest-xdist
- name: Launch tests
run: python -m pytest
run: python -m pytest -n auto
- name: Check coding style
run: python -m flake8
- name: Check imports order
run: python -m isort . --check --diff
12 changes: 10 additions & 2 deletions docs/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ Tests
-----

Tests are stored in the ``tests`` folder at the top of the repository. They use
the `pytest`_ library.
the pytest_ library.

You can launch tests (with code coverage and lint) using the following command::
You can launch tests using the following command::

venv/bin/python -m pytest

WeasyPrint also uses isort_ to check imports and flake8_ to check the coding
style::

venv/bin/python -m isort . --check --diff
venv/bin/python -m flake8

.. _pytest: https://docs.pytest.org/
.. _isort: https://pycqa.github.io/isort/
.. _flake8: https://flake8.pycqa.org/


Documentation
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ Donation = 'https://opencollective.com/courtbouillon'

[project.optional-dependencies]
doc = ['sphinx', 'sphinx_rtd_theme']
# TODO: remove the flake8 dependency when https://github.com/tholo/pytest-flake8/issues/87 is fixed
test = ['pytest', 'pytest-xdist', 'pytest-flake8', 'pytest-isort', 'pytest-cov', 'coverage[toml]', 'flake8 <5']
test = ['pytest', 'isort', 'flake8']

[project.scripts]
weasyprint = 'weasyprint.__main__:main'

[tool.flit.sdist]
exclude = ['.*']

[tool.pytest.ini_options]
addopts = '--isort --flake8 --numprocesses=auto'

[tool.coverage.run]
branch = true
include = ['tests/*', 'weasyprint/*']
Expand Down

0 comments on commit b9c086d

Please sign in to comment.