From 23fe80f191c515414663afa6b251fea8444272b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Thu, 14 Nov 2019 11:48:27 +0100 Subject: [PATCH 1/4] Add pytest-flake8 --- .travis.yml | 31 +++++++++++++++++++++---------- conftest.py | 8 ++++++++ pytest.ini | 8 ++++++++ tox.ini | 10 +++++++++- 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 conftest.py create mode 100644 pytest.ini diff --git a/.travis.yml b/.travis.yml index 69ecf93..1f00f69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,25 @@ language: python -python: -- '2.7' -- '3.4' -- '3.5' -- '3.6' -- '3.7' +matrix: + include: + - python: 3.8 + env: TOXENV=flake8 + - python: 2.7 + env: TOXENV=py27 + - python: pypy + env: TOXENV=pypy + - python: 3.4 + env: TOXENV=py34 + - python: 3.5 + env: TOXENV=py35 + - python: 3.6 + env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 + - python: pypy3 + env: TOXENV=pypy3 install: -- pip install -r tests/requirements.txt -e . -script: -- py.test --cov-report term --cov=cssselect +- pip install tox -r tests/requirements.txt -e . +script: tox after_success: - codecov deploy: @@ -21,4 +32,4 @@ deploy: on: tags: true repo: scrapy/cssselect - condition: "$TRAVIS_PYTHON_VERSION == '3.7'" + condition: "$TOXENV == py37" diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..5a2b401 --- /dev/null +++ b/conftest.py @@ -0,0 +1,8 @@ +def pytest_collection_modifyitems(session, config, items): + # Avoid executing tests when executing `--flake8` flag (pytest-flake8) + try: + from pytest_flake8 import Flake8Item + if config.getoption('--flake8'): + items[:] = [item for item in items if isinstance(item, Flake8Item)] + except ImportError: + pass diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..04fbe03 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,8 @@ +[pytest] +flake8-ignore = + setup.py E131 E251 + cssselect/__init__.py F401 + cssselect/parser.py E128 E225 E226 E266 E302 E305 E501 F821 W503 W504 + cssselect/xpath.py E121 E123 E128 E131 E221 E222 E225 E226 E266 E301 E303 E501 F821 + docs/conf.py E121 E122 E265 E401 E501 F401 + tests/test_cssselect.py E101 E122 E124 E128 E131 E261 E265 E266 E305 E501 W191 diff --git a/tox.ini b/tox.ini index 32136a0..0c9b813 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34, py35, py36, py37 +envlist = py27, pypy, py34, py35, py36, py37, pypy3 [testenv] deps= @@ -7,3 +7,11 @@ deps= commands = py.test --cov-report term --cov=cssselect + +[testenv:flake8] +basepython = python3 +deps = + {[testenv]deps} + pytest-flake8 +commands = + pytest --flake8 . From 11d718803cd111cbb4fee57a5b7ecc8960a1026e Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Wed, 23 Jun 2021 10:38:05 -0300 Subject: [PATCH 2/4] Add flake8 to CI --- .github/workflows/checks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 99fff74..2f38d19 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,6 +7,9 @@ jobs: strategy: matrix: include: + - python-version: 3 + env: + TOXENV: flake8 - python-version: 3 env: TOXENV: security From 66a0e4b603663a8e435caded0ac32b3fa0648cd7 Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Wed, 23 Jun 2021 10:41:04 -0300 Subject: [PATCH 3/4] Remove conftest.py --- conftest.py | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 conftest.py diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 5a2b401..0000000 --- a/conftest.py +++ /dev/null @@ -1,8 +0,0 @@ -def pytest_collection_modifyitems(session, config, items): - # Avoid executing tests when executing `--flake8` flag (pytest-flake8) - try: - from pytest_flake8 import Flake8Item - if config.getoption('--flake8'): - items[:] = [item for item in items if isinstance(item, Flake8Item)] - except ImportError: - pass From 8e45343533ea89dfe07ead4fd0c122361f91042b Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Wed, 23 Jun 2021 10:42:29 -0300 Subject: [PATCH 4/4] Update tox.ini --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 77e0a22..5ae98ce 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,13 @@ envlist = flake8,security,py [testenv] +basepython = python3 deps= -r tests/requirements.txt commands = py.test --cov-report term --cov=cssselect [testenv:flake8] -basepython = python3 deps = flake8==3.9.2 commands = @@ -18,4 +18,4 @@ commands = deps = bandit commands = - bandit -r -c .bandit.yml {posargs:cssselect} + bandit -r -c .bandit.yml {posargs: cssselect}