Merge ~cjwatson/lazr.config:rhinectomy into lazr.config:main

Proposed by Colin Watson
Status: Merged
Merged at revision: e4b2f8cfb6bcbf6e5475b8a9a1adfa8541631af6
Proposed branch: ~cjwatson/lazr.config:rhinectomy
Merge into: lazr.config:main
Diff against target: 236 lines (+96/-32)
5 files modified
.gitignore (+1/-0)
NEWS.rst (+1/-0)
dev/null (+0/-27)
src/lazr/config/tests/test_docs.py (+67/-0)
tox.ini (+27/-5)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+412135@code.launchpad.net

Commit message

Test using zope.testrunner rather than nose

Description of the change

`nose` is unmaintained and doesn't work with Python 3.10. There's `nose2`, but using `zope.testrunner` brings this more into line with other lazr.* projects.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Ok, I had to google rhinectomy but I still laughed :)

Hm, coverage is failing for me as 1% is missing. I am pretty sure you ran it, maybe we run a different Python version for coverage? 3.8.10 for me.

Could you please lower the minimum required coverage?

Thank you.

review: Needs Fixing
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

$ tox -e coverage
GLOB sdist-make: /home/jugmac00/Projects/lazr.config/setup.py
coverage inst-nodeps: /home/jugmac00/Projects/lazr.config/.tox/.tmp/package/1/lazr.config-2.2.3.zip
coverage installed: coverage==6.1.2,lazr.config @ file:///home/jugmac00/Projects/lazr.config/.tox/.tmp/package/1/lazr.config-2.2.3.zip,lazr.delegates==2.0.4,nose==1.3.7,six==1.16.0,zope.exceptions==4.4,zope.interface==5.4.0,zope.testrunner==5.4.0
coverage run-test-pre: PYTHONHASHSEED='3527834898'
coverage run-test: commands[0] | python --version
Python 3.8.10
coverage run-test: commands[1] | coverage erase
coverage run-test: commands[2] | coverage run -m zope.testrunner --test-path src --tests-pattern '^tests'
Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
  Ran 24 tests with 0 failures, 0 errors and 0 skipped in 0.049 seconds.
Tearing down left over layers:
  Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
coverage run-test: commands[3] | coverage html
Wrote HTML report to htmlcov/index.html
coverage run-test: commands[4] | coverage report -m --fail-under=97
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------------------------------------------
.tox/coverage/lib/python3.8/site-packages/lazr/config/__init__.py 5 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/_config.py 444 12 97% 55-61, 416, 560, 629, 684, 838, 841, 850
.tox/coverage/lib/python3.8/site-packages/lazr/config/_version.py 1 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/docs/__init__.py 0 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/interfaces.py 52 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/tests/__init__.py 0 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/tests/test_config.py 123 11 91% 31-33, 36-38, 154, 163-165, 172, 176-178
.tox/coverage/lib/python3.8/site-packages/lazr/config/tests/test_docs.py 19 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/config/tests/testdata/__init__.py 0 0 100%
----------------------------------------------------------------------------------------------------------------
TOTAL 644 23 96%
Coverage failure: total of 96 is less than fail-under=97
ERROR: InvocationError for command /home/jugmac00/Projects/lazr.config/.tox/coverage/bin/coverage report -m --fail-under=97 (exited with code 2)
_________________________________________________________________________________ summary _________________________________________________________________________________
ERROR: coverage: commands failed

Revision history for this message
Colin Watson (cjwatson) wrote :

The difference is that src/lazr/config/_config.py:560 is covered when I run the tests but apparently not for you. I'm not quite sure why that would be, but regardless, I've lowered the required percentage slightly for now.

Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Thanks! Not going down this rabbit hole :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.coverage b/.coverage
0deleted file mode 1006440deleted file mode 100644
index 33846df..0000000
1Binary files a/.coverage and /dev/null differ1Binary files a/.coverage and /dev/null differ
diff --git a/.gitignore b/.gitignore
index cff4a80..2964eac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,5 @@ dist
12.tox12.tox
13__pycache__13__pycache__
14.coverage14.coverage
15htmlcov
15src/lazr/config/docs/_build16src/lazr/config/docs/_build
diff --git a/NEWS.rst b/NEWS.rst
index 58e26ba..d7a814b 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -7,6 +7,7 @@ NEWS for lazr.config
7- Add basic pre-commit configuration.7- Add basic pre-commit configuration.
8- Publish Documentation on Read the Docs.8- Publish Documentation on Read the Docs.
9- Apply inclusive naming via the woke pre-commit hook.9- Apply inclusive naming via the woke pre-commit hook.
10- Test using ``zope.testrunner`` rather than ``nose``.
1011
112.2.3 (2021-01-26)122.2.3 (2021-01-26)
12==================13==================
diff --git a/setup.cfg b/setup.cfg
13deleted file mode 10064414deleted file mode 100644
index c7266bb..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
1[nosetests]
2verbosity=3
3with-coverage=1
4with-doctest=1
5doctest-extension=.rst
6doctest-options=+ELLIPSIS,+NORMALIZE_WHITESPACE,+REPORT_NDIFF
7doctest-fixtures=_fixture
8cover-package=lazr.config
9pdb=1
diff --git a/src/lazr/config/docs/fixture.py b/src/lazr/config/docs/fixture.py
10deleted file mode 1006440deleted file mode 100644
index c1e3c1e..0000000
--- a/src/lazr/config/docs/fixture.py
+++ /dev/null
@@ -1,34 +0,0 @@
1# Copyright 2009-2015 Canonical Ltd. All rights reserved.
2#
3# This file is part of lazr.smtptest
4#
5# lazr.smtptest is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation, version 3 of the License.
8#
9# lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12# License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with lazr.smtptest. If not, see <http://www.gnu.org/licenses/>.
16
17"""Doctest fixtures for running under nose."""
18
19from __future__ import absolute_import, print_function, unicode_literals
20
21__metaclass__ = type
22__all__ = [
23 'globs',
24 ]
25
26
27def globs(globs):
28 """Set up globals for doctests."""
29 # Enable future statements to make Python 2 act more like Python 3.
30 globs['absolute_import'] = absolute_import
31 globs['print_function'] = print_function
32 globs['unicode_literals'] = unicode_literals
33 # Provide a convenient way to clean things up at the end of the test.
34 return globs
diff --git a/src/lazr/config/docs/usage_fixture.py b/src/lazr/config/docs/usage_fixture.py
35deleted file mode 1006440deleted file mode 100644
index 280d5c9..0000000
--- a/src/lazr/config/docs/usage_fixture.py
+++ /dev/null
@@ -1,27 +0,0 @@
1# Copyright 2009-2015 Canonical Ltd. All rights reserved.
2#
3# This file is part of lazr.smtptest
4#
5# lazr.smtptest is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation, version 3 of the License.
8#
9# lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12# License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with lazr.smtptest. If not, see <http://www.gnu.org/licenses/>.
16
17"""Doctest fixtures for running under nose."""
18
19from __future__ import absolute_import, print_function, unicode_literals
20
21__metaclass__ = type
22__all__ = [
23 'globs',
24 ]
25
26
27from lazr.config.docs.fixture import globs
diff --git a/src/lazr/config/tests/test_docs.py b/src/lazr/config/tests/test_docs.py
28new file mode 1006440new file mode 100644
index 0000000..eb44411
--- /dev/null
+++ b/src/lazr/config/tests/test_docs.py
@@ -0,0 +1,67 @@
1# Copyright 2009-2021 Canonical Ltd. All rights reserved.
2#
3# This file is part of lazr.config.
4#
5# lazr.config is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation, version 3 of the License.
8#
9# lazr.config is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12# License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with lazr.config. If not, see <http://www.gnu.org/licenses/>.
16
17"""Test harness for doctests."""
18
19from __future__ import absolute_import, print_function, unicode_literals
20
21__metaclass__ = type
22__all__ = []
23
24import atexit
25import doctest
26import os
27
28from pkg_resources import (
29 resource_filename,
30 resource_exists,
31 resource_listdir,
32 cleanup_resources,
33)
34
35
36DOCTEST_FLAGS = (
37 doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF
38)
39
40
41def load_tests(loader, tests, pattern):
42 """Load the doc tests (docs/*, if any exist)."""
43 doctest_files = []
44 if resource_exists("lazr.config", "docs"):
45 for name in resource_listdir("lazr.config", "docs"):
46 if name.endswith(".rst"):
47 doctest_files.append(
48 os.path.abspath(
49 resource_filename("lazr.config", "docs/%s" % name)
50 )
51 )
52 atexit.register(cleanup_resources)
53 globs = {
54 "absolute_import": absolute_import,
55 "print_function": print_function,
56 "unicode_literals": unicode_literals,
57 }
58 tests.addTest(
59 doctest.DocFileSuite(
60 *doctest_files,
61 module_relative=False,
62 optionflags=DOCTEST_FLAGS,
63 globs=globs,
64 encoding="UTF-8"
65 )
66 )
67 return tests
diff --git a/tox.ini b/tox.ini
index c6ab782..24f5373 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,13 +1,19 @@
1[tox]1[tox]
2envlist = py27,py34,py35,py36,py37,py382envlist =
3 py27
4 py34
5 py35
6 py36
7 py37
8 py38
9 coverage
3skip_missing_interpreters = True10skip_missing_interpreters = True
411
5
6[testenv]12[testenv]
7commands = python -s -m nose -P lazr
8deps =13deps =
9 nose14 zope.testrunner
10 coverage15commands =
16 zope-testrunner --test-path src --tests-pattern ^tests {posargs}
1117
12[testenv:pre-commit]18[testenv:pre-commit]
13commands =19commands =
@@ -32,3 +38,19 @@ commands =
32 sphinx-build -b html -d src/lazr/config/docs/_build/doctrees src/lazr/config/docs src/lazr/config/docs/_build/html38 sphinx-build -b html -d src/lazr/config/docs/_build/doctrees src/lazr/config/docs src/lazr/config/docs/_build/html
33deps =39deps =
34 .[docs]40 .[docs]
41
42[testenv:coverage]
43basepython =
44 python3
45deps =
46 coverage
47 zope.testrunner
48commands =
49 coverage erase
50 coverage run -m zope.testrunner --test-path src --tests-pattern ^tests {posargs}
51 coverage html
52 coverage report -m --fail-under=96
53
54[coverage:run]
55source = lazr.config
56omit = */docs/conf.py

Subscribers

People subscribed via source and target branches