From f9d93c0880ffd200d335d1709922ccc81b0f9fa8 Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Mon, 9 Mar 2020 00:32:25 -0400 Subject: [PATCH] Add static analysis for tests to toxfile --- tests/fixtures.py | 3 ++- tests/test_database_account.py | 1 + tests/test_database_domain.py | 1 + tox.ini | 19 ++++++++++++++++--- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index f660577..e772985 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -1,9 +1,9 @@ import contextlib import datetime -import _pytest import passlib.hash import pytest +import _pytest # noreorder from keyosk import config from keyosk import database @@ -30,6 +30,7 @@ def sqlite_database(tmp_path): sqlite_path.unlink() +# pylint: disable=too-many-locals @pytest.fixture(scope="module") def demo_database(request, tmp_path_factory): """Generate a database with test data in it for tests""" diff --git a/tests/test_database_account.py b/tests/test_database_account.py index a27f34f..533a6f6 100644 --- a/tests/test_database_account.py +++ b/tests/test_database_account.py @@ -1,3 +1,4 @@ +# pylint: disable=unused-argument,redefined-outer-name,unused-import import copy import passlib diff --git a/tests/test_database_domain.py b/tests/test_database_domain.py index d4889d0..afd2ce9 100644 --- a/tests/test_database_domain.py +++ b/tests/test_database_domain.py @@ -1,3 +1,4 @@ +# pylint: disable=unused-argument,redefined-outer-name,unused-import import copy import datetime diff --git a/tox.ini b/tox.ini index b3aef71..ded16db 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py36, py37, py38, format, static, docs +envlist = py36, py37, py38, format, static, static-tests, docs skip_missing_interpreters = true isolated_build = true @@ -16,7 +16,7 @@ commands = pytest --cov={envsitepackagesdir}/keyosk --cov-config .coveragerc tests/ --cov-report term-missing [testenv:format] -description = Enforce code formatting (pre-commit) +description = Enforce file formatting (pre-commit) skip_install = true deps = pre-commit == 2.1.0 @@ -25,7 +25,6 @@ commands = [testenv:static] description = Static code analysis (mypy+pylint+bandit) -skip_install = true ignore_errors = true deps = pylint == 2.3.1 @@ -37,6 +36,20 @@ commands = pylint keyosk --rcfile .pylintrc bandit --recursive keyosk +[testenv:static-tests] +description = Static code analysis for the tests (mypy+pylint+bandit) +ignore_errors = true +deps = + pytest == 5.3.5 + pylint == 2.3.1 + astroid == 2.2.5 + mypy == 0.761 + bandit == 1.6.2 +commands = + mypy tests --ignore-missing-imports --no-strict-optional + pylint tests --rcfile .pylintrc + bandit --recursive tests --skip B101 + [testenv:docs] description = Build documentation (sphinx) deps =