diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index 45382bc548..bfa299eb30 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -31,8 +31,6 @@ createvirtualenv () { python -m pip install --upgrade pip python -m pip install --upgrade setuptools wheel tox - # lxml only has wheels for macos 10.15+ - python -m pip install unittest-xml-reporting || true } # Usage: diff --git a/mypy.ini b/mypy.ini index d0e6ab5ff9..3cd1d89d1d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -37,6 +37,3 @@ warn_unused_ignores = True [mypy-winkerberos.*] ignore_missing_imports = True - -[mypy-xmlrunner.*] -ignore_missing_imports = True diff --git a/setup.py b/setup.py index c900564415..144ce98503 100755 --- a/setup.py +++ b/setup.py @@ -8,71 +8,11 @@ except ImportError: pass -from setuptools import Command, setup +from setuptools import setup from setuptools.command.build_ext import build_ext from setuptools.extension import Extension -class test(Command): - description = "run the tests" - - user_options = [ - ("test-module=", "m", "Discover tests in specified module"), - ("test-suite=", "s", "Test suite to run (e.g. 'some_module.test_suite')"), - ("failfast", "f", "Stop running tests on first failure or error"), - ("xunit-output=", "x", "Generate a results directory with XUnit XML format"), - ] - - def initialize_options(self): - self.test_module = None - self.test_suite = None - self.failfast = False - self.xunit_output = None - - def finalize_options(self): - if self.test_suite is None and self.test_module is None: - self.test_module = "test" - elif self.test_module is not None and self.test_suite is not None: - raise Exception("You may specify a module or suite, but not both") - - def run(self): - # Installing required packages, running egg_info and build_ext are - # part of normal operation for setuptools.command.test.test - if self.distribution.install_requires: - self.distribution.fetch_build_eggs(self.distribution.install_requires) - if self.distribution.tests_require: - self.distribution.fetch_build_eggs(self.distribution.tests_require) - if self.xunit_output: - self.distribution.fetch_build_eggs(["unittest-xml-reporting"]) - self.run_command("egg_info") - build_ext_cmd = self.reinitialize_command("build_ext") - build_ext_cmd.inplace = 1 - self.run_command("build_ext") - - # Construct a TextTestRunner directly from the unittest imported from - # test, which creates a TestResult that supports the 'addSkip' method. - # setuptools will by default create a TextTestRunner that uses the old - # TestResult class. - from test import PymongoTestRunner, test_cases, unittest - - if self.test_suite is None: - all_tests = unittest.defaultTestLoader.discover(self.test_module) - suite = unittest.TestSuite() - suite.addTests(sorted(test_cases(all_tests), key=lambda x: x.__module__)) - else: - suite = unittest.defaultTestLoader.loadTestsFromName(self.test_suite) - if self.xunit_output: - from test import PymongoXMLTestRunner - - runner = PymongoXMLTestRunner( - verbosity=2, failfast=self.failfast, output=self.xunit_output - ) - else: - runner = PymongoTestRunner(verbosity=2, failfast=self.failfast) - result = runner.run(suite) - sys.exit(not result.wasSuccessful()) - - class custom_build_ext(build_ext): """Allow C extension building to fail. @@ -189,6 +129,4 @@ def build_extension(self, ext): ) ext_modules = [] -setup( - cmdclass={"build_ext": custom_build_ext, "test": test}, ext_modules=ext_modules -) # type:ignore +setup(cmdclass={"build_ext": custom_build_ext}, ext_modules=ext_modules) # type:ignore diff --git a/test/__init__.py b/test/__init__.py index 0c7b574ee2..d025d7e081 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -28,14 +28,6 @@ import unittest import warnings -try: - from xmlrunner import XMLTestRunner - - HAVE_XML = True -# ValueError is raised when version 3+ is installed on Jython 2.7. -except (ImportError, ValueError): - HAVE_XML = False - try: import ipaddress # noqa @@ -1240,24 +1232,6 @@ def teardown(): print_running_clients() -class PymongoTestRunner(unittest.TextTestRunner): - def run(self, test): - setup() - result = super().run(test) - teardown() - return result - - -if HAVE_XML: - - class PymongoXMLTestRunner(XMLTestRunner): # type: ignore[misc] - def run(self, test): - setup() - result = super().run(test) - teardown() - return result - - def test_cases(suite): """Iterator over all TestCases within a TestSuite.""" for suite_or_case in suite._tests: