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

Skip to content

Commit 4a705d1

Browse files
committed
Merge pull request #5434 from jenshnielsen/nosetuptest
Remove setup.py tests and adapt docs to use tests.py conflicts in setup.py due to parts of #5604 being back-ported as well. Removed the windows bdist patch code to resolve.
1 parent 9ca65d8 commit 4a705d1

File tree

2 files changed

+6
-124
lines changed

2 files changed

+6
-124
lines changed

setup.py

Lines changed: 4 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -127,116 +127,13 @@
127127
]
128128

129129

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

238135
cmdclass = versioneer.get_cmdclass()
239-
cmdclass['test'] = NoseTestCommand
136+
cmdclass['test'] = NoopTestCommand
240137

241138
# One doesn't normally see `if __name__ == '__main__'` blocks in a setup.py,
242139
# however, this is needed on Windows to avoid creating infinite subprocesses
@@ -252,7 +149,6 @@ def run_tests(self):
252149
package_dir = {'': 'lib'}
253150
install_requires = []
254151
setup_requires = []
255-
tests_require = []
256152
default_backend = None
257153

258154
# Go through all of the packages and figure out which ones we are
@@ -313,7 +209,6 @@ def run_tests(self):
313209
package_data[key] = list(set(val + package_data[key]))
314210
install_requires.extend(package.get_install_requires())
315211
setup_requires.extend(package.get_setup_requires())
316-
tests_require.extend(package.get_tests_require())
317212

318213
# Write the default matplotlibrc file
319214
if default_backend is None:
@@ -373,7 +268,6 @@ def run_tests(self):
373268
# List third-party Python packages that we require
374269
install_requires=install_requires,
375270
setup_requires=setup_requires,
376-
tests_require=tests_require,
377271

378272
# matplotlib has C/C++ extensions, so it's not zip safe.
379273
# 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
@@ -426,12 +426,6 @@ def get_setup_requires(self):
426426
"""
427427
return []
428428

429-
def get_tests_require(self):
430-
"""
431-
Get a list of Python packages that we require for executing tests.
432-
"""
433-
return []
434-
435429
def _check_for_pkg_config(self, package, include_file, min_version=None,
436430
version=None):
437431
"""
@@ -664,8 +658,8 @@ def check(self):
664658

665659
msgs = []
666660
msg_template = ('{package} is required to run the matplotlib test '
667-
'suite. "setup.py test" will automatically download it.'
668-
' Install {package} to run matplotlib.test()')
661+
'suite. Please install it with pip or your preferred'
662+
' tool to run the test suite')
669663

670664
bad_nose = msg_template.format(
671665
package='nose %s or later' % self.nose_min_version
@@ -713,12 +707,6 @@ def get_package_data(self):
713707
'sphinxext/tests/tinypages/_static/*',
714708
]}
715709

716-
def get_tests_require(self):
717-
requires = ['nose>=%s' % self.nose_min_version, 'sphinx']
718-
if not sys.version_info >= (3, 3):
719-
requires += ['mock']
720-
return requires
721-
722710

723711
class Toolkits_Tests(Tests):
724712
name = "toolkits_tests"

0 commit comments

Comments
 (0)