From 12b0f83762e782d410c2f28d7f32c796495eefaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 12 Aug 2020 15:23:55 +0200 Subject: [PATCH] Test with Python 3.9 as well --- .github/workflows/main.yaml | 3 +++ README.rst | 4 ++-- setup.py | 1 + tests/fixtures/tox.ini | 2 +- tests/test_integration.py | 37 +++++++++++++++++++++---------------- tox.ini | 2 +- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0a601e6..782acd0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -22,14 +22,17 @@ jobs: - py36-tox35 - py37-tox35 - py38-tox35 + - py39-tox35 - py36-toxrelease - py37-toxrelease - py38-toxrelease + - py39-toxrelease - py36-toxmaster - py37-toxmaster - py38-toxmaster + - py39-toxmaster # Use GitHub's Linux Docker host runs-on: ubuntu-latest diff --git a/README.rst b/README.rst index 3afd275..514decd 100644 --- a/README.rst +++ b/README.rst @@ -214,8 +214,8 @@ or send Pull Requests. Tests ~~~~~ -In order to run the tests, you'll need ``tox`` and Python 3.6, 3.7 and 3.8 installed. -The integration tests assume all three are available. +In order to run the tests, you'll need ``tox`` and Python 3.6, 3.7, 3.8 and 3.9 installed. +The integration tests assume all four are available. On Fedora, you just need to ``dnf install tox``. Run ``tox`` to invoke the tests. diff --git a/setup.py b/setup.py index 6b29e4b..933132b 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ setup( "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Testing", ], diff --git a/tests/fixtures/tox.ini b/tests/fixtures/tox.ini index 3d3982b..56979da 100644 --- a/tests/fixtures/tox.ini +++ b/tests/fixtures/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py36,py37,py38 +envlist = py36,py37,py38,py39 [testenv] deps = diff --git a/tests/test_integration.py b/tests/test_integration.py index 54f51dd..6e8e12d 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -49,17 +49,14 @@ def is_available(python): TOX_VERSION = version.parse(tox("--version").stdout.split(" ")[0]) +TOX38 = TOX_VERSION >= version.parse("3.8") +needs_tox38 = pytest.mark.skipif(not TOX38, reason="This test needs at least tox 3.8") -needs_py3678 = pytest.mark.skipif( - not is_available("python3.6") - or not is_available("python3.7") - or not is_available("python3.8"), - reason="This test needs all of python3.6, python3.7 and python3.8 to be available in $PATH", +needs_py36789 = pytest.mark.skipif( + not all((is_available(f"python3.{x}") for x in range(6, 10))), + reason="This test needs python3.6, 3.7, 3.8 and 3.9 available in $PATH", ) -needs_tox38 = pytest.mark.skipif( - TOX_VERSION < version.parse("3.8"), reason="This test needs at least tox 3.8" -) def test_native_toxenv_current_env(): @@ -68,7 +65,7 @@ def test_native_toxenv_current_env(): assert not (DOT_TOX / NATIVE_TOXENV / "lib").is_dir() -@needs_py3678 +@needs_py36789 def test_all_toxenv_current_env(): result = tox("--current-env", check=False) assert NATIVE_EXEC_PREFIX_MSG in result.stdout.splitlines() @@ -87,7 +84,7 @@ def test_missing_toxenv_current_env(python): assert result.returncode > 0 -@needs_py3678 +@needs_py36789 def test_all_toxenv_current_env_skip_missing(): result = tox("--current-env", "--skip-missing-interpreters", check=False) assert "InterpreterMismatch:" in result.stdout @@ -95,7 +92,7 @@ def test_all_toxenv_current_env_skip_missing(): assert result.returncode == 0 -@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38"]) +@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"]) def test_print_deps_only(toxenv): result = tox("-e", toxenv, "--print-deps-only") expected = textwrap.dedent( @@ -120,17 +117,20 @@ def test_allenvs_print_deps_only(): py six py + six + py ___________________________________ summary ____________________________________ py36: commands succeeded py37: commands succeeded py38: commands succeeded + py39: commands succeeded congratulations :) """ ).lstrip() assert result.stdout == expected -@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38"]) +@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"]) def test_print_deps_to_file(toxenv, tmp_path): depspath = tmp_path / "deps" result = tox("-e", toxenv, "--print-deps-to-file", str(depspath)) @@ -148,13 +148,14 @@ def test_print_deps_to_file(toxenv, tmp_path): def test_allenvs_print_deps_to_file(tmp_path): depspath = tmp_path / "deps" result = tox("--print-deps-to-file", str(depspath)) - assert depspath.read_text().splitlines() == ["six", "py"] * 3 + assert depspath.read_text().splitlines() == ["six", "py"] * 4 expected = textwrap.dedent( """ ___________________________________ summary ____________________________________ py36: commands succeeded py37: commands succeeded py38: commands succeeded + py39: commands succeeded congratulations :) """ ).lstrip() @@ -184,15 +185,19 @@ def test_print_deps_only_print_deps_to_file_are_mutually_exclusive(): assert "cannot be used together" in result.stderr -@needs_py3678 +@needs_py36789 def test_regular_run(): result = tox() - lines = sorted(result.stdout.splitlines()[:3]) + lines = sorted(result.stdout.splitlines()[:4]) assert "/.tox/py36 is the exec_prefix" in lines[0] assert "/.tox/py37 is the exec_prefix" in lines[1] assert "/.tox/py38 is the exec_prefix" in lines[2] + assert "/.tox/py39 is the exec_prefix" in lines[3] assert "congratulations" in result.stdout - for y in 6, 7, 8: + for y in 6, 7, 8, 9: + if y == 9 and not TOX38: + # tox 3.5 cannot handle Python 3.9 venvs + continue for pkg in "py", "six", "test": sitelib = DOT_TOX / f"py3{y}/lib/python3.{y}/site-packages" assert sitelib.is_dir() diff --git a/tox.ini b/tox.ini index 26e8b3c..c87a2a9 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ # This information is repeated in .github/workflows/main.yaml # (see https://github.com/fedora-python/tox-github-action/issues/8) -envlist = {py36,py37,py38}-tox{35,release,master} +envlist = {py36,py37,py38,py39}-tox{35,release,master} [testenv] deps=