From bab8e4a1e13b9c5ee4d3219701e011c315422e5e Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Fri, 10 Nov 2023 07:11:56 -0600 Subject: [PATCH] Use tox to run the test suite against all supported Pythons --- .coveragerc | 4 ++++ .github/workflows/ci.yml | 2 +- .gitignore | 6 +++-- Makefile | 8 ++----- requirements-dev.txt | 5 +---- tox.ini | 48 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc index 98d6664..1cdfe06 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,7 @@ [run] +parallel = True branch = True source = jsonpath_ng, tests + +[report] +fail_under = 82 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d39b39a..3793658 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,4 +32,4 @@ jobs: pip install -r requirements.txt pip install -r requirements-dev.txt - name: Run tests - run: make test + run: tox run -e py${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index ff083c8..a3438e2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,13 +6,15 @@ \#( .\#* -# Built artifacts +# Build and test artifacts /README.txt /dist /*.egg-info parser.out -.coverage .cache +.coverage +.coverage.* +.tox/ build /jsonpath_rw/VERSION diff --git a/Makefile b/Makefile index 8de0cb0..75a273a 100644 --- a/Makefile +++ b/Makefile @@ -23,12 +23,8 @@ lint: @flake8 --exclude=tests . test: clean - @echo "$(OK_COLOR)==> Runnings tests ...$(NO_COLOR)" - @pytest -s -v --capture sys --cov jsonpath_ng --cov-report term-missing - -coverage: - @coverage run --source jsonpath_ng -m pytest - @coverage report + @echo "$(OK_COLOR)==> Running tests ...$(NO_COLOR)" + @tox tag: @echo "$(OK_COLOR)==> Creating tag $(version) ...$(NO_COLOR)" diff --git a/requirements-dev.txt b/requirements-dev.txt index 99d817a..ccdfca6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,2 @@ -pytest +tox flake8 -coverage -pytest-cov -pytest-randomly diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..926b6d4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,48 @@ +[tox] +min_version = 4.3.5 + +envlist = + coverage-erase + py{3.12, 3.11, 3.10, 3.9, 3.8, 3.7} + coverage-report + +skip_missing_interpreters = True +isolated_build = True + + +[testenv] +package = wheel +wheel_build_env = build_wheel + +depends = + py{3.12, 3.11, 3.10, 3.9, 3.8, 3.7}: coverage-erase +deps = + coverage[toml] + pytest + pytest-randomly +commands = + coverage run -m pytest + + +[testenv:coverage-erase] +no_package = true +skip_install = true +deps = + coverage[toml] +commands = + coverage erase + + +[testenv:coverage-report] +depends = + py{3.12, 3.11, 3.10, 3.9, 3.8, 3.7} +no_package = true +skip_install = true +deps = + coverage[toml] +commands_pre = + - coverage combine +commands = + coverage report +command_post = + coverage html --fail-under=0