From 325677384681cb7b12c1bb25ec3a118265103e2a Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 6 Sep 2022 22:28:53 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20pytest=20plugins=20by=20d?= =?UTF-8?q?efault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 6 +++++- docs/contribute.rst | 25 +++++++++++++++---------- pyproject.toml | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 092c065..7ef332d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,11 @@ jobs: python-version: ${{ matrix.python-version }} - name: Upgrade pip and setuptools run: python -m pip install --upgrade pip setuptools - - name: Install tests's requirements + - name: Install tests’ requirements run: python -m pip install .[test] - name: Launch tests run: python -m pytest + - name: Check coding style + run: python -m flake8 --exclude tests/css-parsing-tests + - name: Check imports order + run: python -m isort . --check --diff diff --git a/docs/contribute.rst b/docs/contribute.rst index 8f35a63..c45c21f 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -13,11 +13,9 @@ install tinycss2 dependencies. git clone https://github.com/Kozea/tinycss2.git cd tinycss2 python -m venv venv - venv/bin/pip install .[doc,test] + venv/bin/pip install -e .[doc,test] -You can then let your terminal in the current directory and launch Python to -test your changes. ``import tinycss2`` will then import the working directory -code, so that you can modify it and test your changes. +You can then launch Python to test your changes. .. code-block:: shell @@ -27,8 +25,8 @@ code, so that you can modify it and test your changes. Code & Issues ------------- -If you’ve found a bug in tinycss2, it’s time to report it, and to fix it if you -can! +If you’ve found a bug in tinycss2, it’s time to report it, and to fix it if +you can! You can report bugs and feature requests on GitHub_. If you want to add or fix some code, please fork the repository and create a pull request, we’ll be @@ -43,11 +41,19 @@ Tests Tests are stored in the ``tests`` folder at the top of the repository. They use 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 +tinycss2 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 --exclude tests/css-parsing-tests + .. _pytest: https://docs.pytest.org/ +.. _isort: https://pycqa.github.io/isort/ +.. _flake8: https://flake8.pycqa.org/ Documentation @@ -60,8 +66,7 @@ You can build the documentation using the following command:: venv/bin/sphinx-build docs docs/_build -The documentation home page can now be found in the -``/path/to/tinycss2/docs/_build/index.html`` file. You can open this file in a -browser to see the final rendering. +The documentation home page can now be found in the ``docs/_build/index.html`` +file. You can open this file in a browser to see the final rendering. .. _Sphinx: https://www.sphinx-doc.org/ diff --git a/pyproject.toml b/pyproject.toml index b7143c3..36a60dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,13 +40,12 @@ Donation = 'https://opencollective.com/courtbouillon' [project.optional-dependencies] doc = ['sphinx', 'sphinx_rtd_theme'] -test = ['pytest', 'pytest-xdist', 'pytest-flake8', 'pytest-isort', 'pytest-cov', 'coverage[toml]'] +test = ['pytest', 'isort', 'flake8'] [tool.flit.sdist] exclude = ['.*'] [tool.pytest.ini_options] -addopts = '--isort --flake8 --numprocesses=auto' norecursedirs = ['tests/css-parsing-tests'] [tool.coverage.run] @@ -60,3 +59,4 @@ omit = ['.*'] [tool.isort] default_section = 'FIRSTPARTY' multi_line_output = 4 +extend_skip = ['tests/css-parsing-tests'] \ No newline at end of file