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
1diff --git a/.coverage b/.coverage
2deleted file mode 100644
3index 33846df..0000000
4Binary files a/.coverage and /dev/null differ
5diff --git a/.gitignore b/.gitignore
6index cff4a80..2964eac 100644
7--- a/.gitignore
8+++ b/.gitignore
9@@ -12,4 +12,5 @@ dist
10 .tox
11 __pycache__
12 .coverage
13+htmlcov
14 src/lazr/config/docs/_build
15diff --git a/NEWS.rst b/NEWS.rst
16index 58e26ba..d7a814b 100644
17--- a/NEWS.rst
18+++ b/NEWS.rst
19@@ -7,6 +7,7 @@ NEWS for lazr.config
20 - Add basic pre-commit configuration.
21 - Publish Documentation on Read the Docs.
22 - Apply inclusive naming via the woke pre-commit hook.
23+- Test using ``zope.testrunner`` rather than ``nose``.
24
25 2.2.3 (2021-01-26)
26 ==================
27diff --git a/setup.cfg b/setup.cfg
28deleted file mode 100644
29index c7266bb..0000000
30--- a/setup.cfg
31+++ /dev/null
32@@ -1,9 +0,0 @@
33-[nosetests]
34-verbosity=3
35-with-coverage=1
36-with-doctest=1
37-doctest-extension=.rst
38-doctest-options=+ELLIPSIS,+NORMALIZE_WHITESPACE,+REPORT_NDIFF
39-doctest-fixtures=_fixture
40-cover-package=lazr.config
41-pdb=1
42diff --git a/src/lazr/config/docs/fixture.py b/src/lazr/config/docs/fixture.py
43deleted file mode 100644
44index c1e3c1e..0000000
45--- a/src/lazr/config/docs/fixture.py
46+++ /dev/null
47@@ -1,34 +0,0 @@
48-# Copyright 2009-2015 Canonical Ltd. All rights reserved.
49-#
50-# This file is part of lazr.smtptest
51-#
52-# lazr.smtptest is free software: you can redistribute it and/or modify it
53-# under the terms of the GNU Lesser General Public License as published by
54-# the Free Software Foundation, version 3 of the License.
55-#
56-# lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT
57-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
58-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
59-# License for more details.
60-#
61-# You should have received a copy of the GNU Lesser General Public License
62-# along with lazr.smtptest. If not, see <http://www.gnu.org/licenses/>.
63-
64-"""Doctest fixtures for running under nose."""
65-
66-from __future__ import absolute_import, print_function, unicode_literals
67-
68-__metaclass__ = type
69-__all__ = [
70- 'globs',
71- ]
72-
73-
74-def globs(globs):
75- """Set up globals for doctests."""
76- # Enable future statements to make Python 2 act more like Python 3.
77- globs['absolute_import'] = absolute_import
78- globs['print_function'] = print_function
79- globs['unicode_literals'] = unicode_literals
80- # Provide a convenient way to clean things up at the end of the test.
81- return globs
82diff --git a/src/lazr/config/docs/usage_fixture.py b/src/lazr/config/docs/usage_fixture.py
83deleted file mode 100644
84index 280d5c9..0000000
85--- a/src/lazr/config/docs/usage_fixture.py
86+++ /dev/null
87@@ -1,27 +0,0 @@
88-# Copyright 2009-2015 Canonical Ltd. All rights reserved.
89-#
90-# This file is part of lazr.smtptest
91-#
92-# lazr.smtptest is free software: you can redistribute it and/or modify it
93-# under the terms of the GNU Lesser General Public License as published by
94-# the Free Software Foundation, version 3 of the License.
95-#
96-# lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT
97-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
98-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
99-# License for more details.
100-#
101-# You should have received a copy of the GNU Lesser General Public License
102-# along with lazr.smtptest. If not, see <http://www.gnu.org/licenses/>.
103-
104-"""Doctest fixtures for running under nose."""
105-
106-from __future__ import absolute_import, print_function, unicode_literals
107-
108-__metaclass__ = type
109-__all__ = [
110- 'globs',
111- ]
112-
113-
114-from lazr.config.docs.fixture import globs
115diff --git a/src/lazr/config/tests/test_docs.py b/src/lazr/config/tests/test_docs.py
116new file mode 100644
117index 0000000..eb44411
118--- /dev/null
119+++ b/src/lazr/config/tests/test_docs.py
120@@ -0,0 +1,67 @@
121+# Copyright 2009-2021 Canonical Ltd. All rights reserved.
122+#
123+# This file is part of lazr.config.
124+#
125+# lazr.config is free software: you can redistribute it and/or modify it
126+# under the terms of the GNU Lesser General Public License as published by
127+# the Free Software Foundation, version 3 of the License.
128+#
129+# lazr.config is distributed in the hope that it will be useful, but WITHOUT
130+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
132+# License for more details.
133+#
134+# You should have received a copy of the GNU Lesser General Public License
135+# along with lazr.config. If not, see <http://www.gnu.org/licenses/>.
136+
137+"""Test harness for doctests."""
138+
139+from __future__ import absolute_import, print_function, unicode_literals
140+
141+__metaclass__ = type
142+__all__ = []
143+
144+import atexit
145+import doctest
146+import os
147+
148+from pkg_resources import (
149+ resource_filename,
150+ resource_exists,
151+ resource_listdir,
152+ cleanup_resources,
153+)
154+
155+
156+DOCTEST_FLAGS = (
157+ doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF
158+)
159+
160+
161+def load_tests(loader, tests, pattern):
162+ """Load the doc tests (docs/*, if any exist)."""
163+ doctest_files = []
164+ if resource_exists("lazr.config", "docs"):
165+ for name in resource_listdir("lazr.config", "docs"):
166+ if name.endswith(".rst"):
167+ doctest_files.append(
168+ os.path.abspath(
169+ resource_filename("lazr.config", "docs/%s" % name)
170+ )
171+ )
172+ atexit.register(cleanup_resources)
173+ globs = {
174+ "absolute_import": absolute_import,
175+ "print_function": print_function,
176+ "unicode_literals": unicode_literals,
177+ }
178+ tests.addTest(
179+ doctest.DocFileSuite(
180+ *doctest_files,
181+ module_relative=False,
182+ optionflags=DOCTEST_FLAGS,
183+ globs=globs,
184+ encoding="UTF-8"
185+ )
186+ )
187+ return tests
188diff --git a/tox.ini b/tox.ini
189index c6ab782..24f5373 100644
190--- a/tox.ini
191+++ b/tox.ini
192@@ -1,13 +1,19 @@
193 [tox]
194-envlist = py27,py34,py35,py36,py37,py38
195+envlist =
196+ py27
197+ py34
198+ py35
199+ py36
200+ py37
201+ py38
202+ coverage
203 skip_missing_interpreters = True
204
205-
206 [testenv]
207-commands = python -s -m nose -P lazr
208 deps =
209- nose
210- coverage
211+ zope.testrunner
212+commands =
213+ zope-testrunner --test-path src --tests-pattern ^tests {posargs}
214
215 [testenv:pre-commit]
216 commands =
217@@ -32,3 +38,19 @@ commands =
218 sphinx-build -b html -d src/lazr/config/docs/_build/doctrees src/lazr/config/docs src/lazr/config/docs/_build/html
219 deps =
220 .[docs]
221+
222+[testenv:coverage]
223+basepython =
224+ python3
225+deps =
226+ coverage
227+ zope.testrunner
228+commands =
229+ coverage erase
230+ coverage run -m zope.testrunner --test-path src --tests-pattern ^tests {posargs}
231+ coverage html
232+ coverage report -m --fail-under=96
233+
234+[coverage:run]
235+source = lazr.config
236+omit = */docs/conf.py

Subscribers

People subscribed via source and target branches