Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e789a70

Browse files
committed
Merge pull request #5434 from jenshnielsen/nosetuptest
Remove setup.py tests and adapt docs to use tests.py
2 parents 3baf47f + d9caef3 commit e789a70

File tree

2 files changed

+6
-125
lines changed

2 files changed

+6
-125
lines changed

setup.py

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -132,114 +132,10 @@
132132
]
133133

134134

135-
class NoseTestCommand(TestCommand):
136-
"""Invoke unit tests using nose after an in-place build."""
137-
138-
description = "Invoke unit tests using nose after an in-place build."
139-
user_options = [
140-
("pep8-only", None, "pep8 checks"),
141-
("omit-pep8", None, "Do not perform pep8 checks"),
142-
("nocapture", None, "do not capture stdout (nosetests)"),
143-
("nose-verbose", None, "be verbose (nosetests)"),
144-
("processes=", None, "number of processes (nosetests)"),
145-
("process-timeout=", None, "process timeout (nosetests)"),
146-
("with-coverage", None, "with coverage"),
147-
("detailed-error-msg", None, "detailed error message (nosetest)"),
148-
("tests=", None, "comma separated selection of tests (nosetest)"),
149-
]
150-
151-
def initialize_options(self):
152-
self.pep8_only = None
153-
self.omit_pep8 = None
154-
155-
# parameters passed to nose tests
156-
self.processes = None
157-
self.process_timeout = None
158-
self.nose_verbose = None
159-
self.nocapture = None
160-
self.with_coverage = None
161-
self.detailed_error_msg = None
162-
self.tests = None
163-
164-
def finalize_options(self):
165-
self.test_args = []
166-
if self.pep8_only:
167-
self.pep8_only = True
168-
if self.omit_pep8:
169-
self.omit_pep8 = True
170-
171-
if self.pep8_only and self.omit_pep8:
172-
from distutils.errors import DistutilsOptionError
173-
raise DistutilsOptionError(
174-
"You are using several options for the test command in an "
175-
"incompatible manner. Please use either --pep8-only or "
176-
"--omit-pep8"
177-
)
178-
179-
if self.processes:
180-
self.test_args.append("--processes={prc}".format(
181-
prc=self.processes))
182-
183-
if self.process_timeout:
184-
self.test_args.append("--process-timeout={tout}".format(
185-
tout=self.process_timeout))
186-
187-
if self.nose_verbose:
188-
self.test_args.append("--verbose")
189-
190-
if self.nocapture:
191-
self.test_args.append("--nocapture")
192-
193-
if self.with_coverage:
194-
self.test_args.append("--with-coverage")
195-
196-
if self.detailed_error_msg:
197-
self.test_args.append("-d")
198-
199-
if self.tests:
200-
self.test_args.append("--tests={names}".format(names=self.tests))
201-
135+
class NoopTestCommand(TestCommand):
202136
def run(self):
203-
if self.distribution.install_requires:
204-
self.distribution.fetch_build_eggs(
205-
self.distribution.install_requires)
206-
if self.distribution.tests_require:
207-
self.distribution.fetch_build_eggs(self.distribution.tests_require)
208-
209-
self.announce('running unittests with nose')
210-
self.with_project_on_sys_path(self.run_tests)
211-
212-
def run_tests(self):
213-
import matplotlib
214-
matplotlib.use('agg')
215-
import nose
216-
from matplotlib.testing.noseclasses import KnownFailure
217-
from matplotlib import default_test_modules as testmodules
218-
from matplotlib import font_manager
219-
import time
220-
# Make sure the font caches are created before starting any possibly
221-
# parallel tests
222-
if font_manager._fmcache is not None:
223-
while not os.path.exists(font_manager._fmcache):
224-
time.sleep(0.5)
225-
plugins = [KnownFailure]
226-
227-
# Nose doesn't automatically instantiate all of the plugins in the
228-
# child processes, so we have to provide the multiprocess plugin
229-
# with a list.
230-
from nose.plugins import multiprocess
231-
multiprocess._instantiate_plugins = plugins
232-
233-
if self.omit_pep8:
234-
testmodules.remove('matplotlib.tests.test_coding_standards')
235-
elif self.pep8_only:
236-
testmodules = ['matplotlib.tests.test_coding_standards']
237-
238-
nose.main(addplugins=[x() for x in plugins],
239-
defaultTest=testmodules,
240-
argv=['nosetests'] + self.test_args,
241-
exit=True)
242-
137+
print("Matplotlib does not support running tests with "
138+
"'python setup.py test'. Please run 'python tests.py'")
243139

244140
class BuildExtraLibraries(BuildExtCommand):
245141
def run(self):
@@ -250,7 +146,7 @@ def run(self):
250146

251147

252148
cmdclass = versioneer.get_cmdclass()
253-
cmdclass['test'] = NoseTestCommand
149+
cmdclass['test'] = NoopTestCommand
254150
cmdclass['build_ext'] = BuildExtraLibraries
255151

256152
# patch bdist_wheel for a bug on windows
@@ -280,7 +176,6 @@ def run(self):
280176
package_dir = {'': 'lib'}
281177
install_requires = []
282178
setup_requires = []
283-
tests_require = []
284179
default_backend = None
285180

286181
# Go through all of the packages and figure out which ones we are
@@ -339,7 +234,6 @@ def run(self):
339234
package_data[key] = list(set(val + package_data[key]))
340235
install_requires.extend(package.get_install_requires())
341236
setup_requires.extend(package.get_setup_requires())
342-
tests_require.extend(package.get_tests_require())
343237

344238
# Write the default matplotlibrc file
345239
if default_backend is None:
@@ -399,7 +293,6 @@ def run(self):
399293
# List third-party Python packages that we require
400294
install_requires=install_requires,
401295
setup_requires=setup_requires,
402-
tests_require=tests_require,
403296

404297
# matplotlib has C/C++ extensions, so it's not zip safe.
405298
# Telling setuptools this prevents it from doing an automatic

setupext.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,6 @@ def get_setup_requires(self):
432432
"""
433433
return []
434434

435-
def get_tests_require(self):
436-
"""
437-
Get a list of Python packages that we require for executing tests.
438-
"""
439-
return []
440-
441435
def _check_for_pkg_config(self, package, include_file, min_version=None,
442436
version=None):
443437
"""
@@ -677,8 +671,8 @@ def check(self):
677671

678672
msgs = []
679673
msg_template = ('{package} is required to run the matplotlib test '
680-
'suite. "setup.py test" will automatically download it.'
681-
' Install {package} to run matplotlib.test()')
674+
'suite. Please install it with pip or your preferred'
675+
' tool to run the test suite')
682676

683677
bad_nose = msg_template.format(
684678
package='nose %s or later' % self.nose_min_version
@@ -727,12 +721,6 @@ def get_package_data(self):
727721
'sphinxext/tests/tinypages/_static/*',
728722
]}
729723

730-
def get_tests_require(self):
731-
requires = ['nose>=%s' % self.nose_min_version, 'sphinx']
732-
if not sys.version_info >= (3, 3):
733-
requires += ['mock']
734-
return requires
735-
736724

737725
class Toolkits_Tests(Tests):
738726
name = "toolkits_tests"

0 commit comments

Comments
 (0)