From e85ba126c56a2ddd3377b0ea6b3d8cbb4bd2f06b Mon Sep 17 00:00:00 2001 From: "aaron.godfrey" Date: Fri, 28 Jun 2019 11:31:10 -0700 Subject: [PATCH 1/7] Bootstrap tests. --- .gitignore | 2 ++ pyproject.toml | 7 +++++++ tests/test_simple.py | 2 ++ tox.ini | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 tests/test_simple.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 256b7e1..ca4300b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +.coverage +.tox dist/ wideq_state.json diff --git a/pyproject.toml b/pyproject.toml index 439cf9c..09e4dc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,3 +12,10 @@ requires = [ ] description-file = "README.md" requires-python = ">=3.4" + +[tool.flit.metadata.requires-extra] +test = [ + "coverage", + "flake8", + "pytest" +] diff --git a/tests/test_simple.py b/tests/test_simple.py new file mode 100644 index 0000000..9d45f4f --- /dev/null +++ b/tests/test_simple.py @@ -0,0 +1,2 @@ +def test_simple(): + assert True diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..5b59bfc --- /dev/null +++ b/tox.ini @@ -0,0 +1,20 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py34,py35,py36,37 +skipsdist = True + +[testenv] +setenv = + PYTHON_EGG_CACHE = {toxworkdir}/egg-cache + PYTHONHASHSEED = 0 +deps = + flit +commands = + flit install + coverage run {envbindir}/pytest {posargs} + coverage report + py37: flake8 From 91f797289b6bb46fa5dbf632634c4b8f46a8a90f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:15:51 -0400 Subject: [PATCH 2/7] Use built-in unittest for test execution I like pytest, but I don't think it's necessary for super simple tests. I'd like to avoid the dependency if we don't need it. --- pyproject.toml | 1 - tox.ini | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 09e4dc1..0785d0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,5 +17,4 @@ requires-python = ">=3.4" test = [ "coverage", "flake8", - "pytest" ] diff --git a/tox.ini b/tox.ini index 5b59bfc..9af01e8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,3 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - [tox] envlist = py34,py35,py36,37 skipsdist = True @@ -15,6 +10,6 @@ deps = flit commands = flit install - coverage run {envbindir}/pytest {posargs} + coverage run python -m unittest -s tests coverage report py37: flake8 From 0fefd70c77ae43bf925b05c6bbac23a58ee980fc Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:18:16 -0400 Subject: [PATCH 3/7] Fix environment name in Tox config --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 9af01e8..f0d89fd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py34,py35,py36,37 +envlist = py34,py35,py36,py37 skipsdist = True [testenv] From 0c4600280f86d5ff4395637557f46a0dae418bc9 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:25:34 -0400 Subject: [PATCH 4/7] Use built-in tox support for PEP 518 We don't need to manually invoke `flit`; with `isolated_build`, tox supports non-setuptools builds out of the box. --- tox.ini | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index f0d89fd..77dfcc3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,12 @@ [tox] envlist = py34,py35,py36,py37 -skipsdist = True +isolated_build = True [testenv] setenv = PYTHON_EGG_CACHE = {toxworkdir}/egg-cache PYTHONHASHSEED = 0 -deps = - flit commands = - flit install coverage run python -m unittest -s tests coverage report py37: flake8 From d306f592e43da7e4f5d62c7c82385fb3b98fa884 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:34:03 -0400 Subject: [PATCH 5/7] tox: Separate flake8 and coverage tesenvs --- tox.ini | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 77dfcc3..6328b0a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,22 @@ [tox] -envlist = py34,py35,py36,py37 +envlist = py34,py35,py36,py37,flake8,coverage isolated_build = True [testenv] -setenv = - PYTHON_EGG_CACHE = {toxworkdir}/egg-cache - PYTHONHASHSEED = 0 commands = - coverage run python -m unittest -s tests + python -m unittest {posargs} discover -s tests + +[testenv:flake8] +basepython = python3.7 +deps = + flake8 +commands = + flake8 {posargs} wideq/ tests/ + +[testenv:coverage] +basepytthon = python3.7 +deps = + coverage +commands = + coverage run -m unittest {posargs} discover -s tests coverage report - py37: flake8 From 6bdb973afe3713218a50a77bf54f6d8d8b1afeab Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:35:49 -0400 Subject: [PATCH 6/7] Tell coverage where the source is Otherwise, it was trying to cover the test files... --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6328b0a..405ccff 100644 --- a/tox.ini +++ b/tox.ini @@ -18,5 +18,5 @@ basepytthon = python3.7 deps = coverage commands = - coverage run -m unittest {posargs} discover -s tests + coverage run --source=wideq -m unittest {posargs} discover -s tests coverage report From 0b9cafc57eb1bc7e7dd88289fb58cb2f79d197a8 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 30 Jun 2019 10:38:50 -0400 Subject: [PATCH 7/7] Test requires are no longer relevant --- pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0785d0f..439cf9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,3 @@ requires = [ ] description-file = "README.md" requires-python = ">=3.4" - -[tool.flit.metadata.requires-extra] -test = [ - "coverage", - "flake8", -]