|
8 | 8 | except ImportError: |
9 | 9 | pass |
10 | 10 |
|
11 | | -from setuptools import Command, setup |
| 11 | +from setuptools import setup |
12 | 12 | from setuptools.command.build_ext import build_ext |
13 | 13 | from setuptools.extension import Extension |
14 | 14 |
|
15 | 15 |
|
16 | | -class test(Command): |
17 | | - description = "run the tests" |
18 | | - |
19 | | - user_options = [ |
20 | | - ("test-module=", "m", "Discover tests in specified module"), |
21 | | - ("test-suite=", "s", "Test suite to run (e.g. 'some_module.test_suite')"), |
22 | | - ("failfast", "f", "Stop running tests on first failure or error"), |
23 | | - ("xunit-output=", "x", "Generate a results directory with XUnit XML format"), |
24 | | - ] |
25 | | - |
26 | | - def initialize_options(self): |
27 | | - self.test_module = None |
28 | | - self.test_suite = None |
29 | | - self.failfast = False |
30 | | - self.xunit_output = None |
31 | | - |
32 | | - def finalize_options(self): |
33 | | - if self.test_suite is None and self.test_module is None: |
34 | | - self.test_module = "test" |
35 | | - elif self.test_module is not None and self.test_suite is not None: |
36 | | - raise Exception("You may specify a module or suite, but not both") |
37 | | - |
38 | | - def run(self): |
39 | | - # Installing required packages, running egg_info and build_ext are |
40 | | - # part of normal operation for setuptools.command.test.test |
41 | | - if self.distribution.install_requires: |
42 | | - self.distribution.fetch_build_eggs(self.distribution.install_requires) |
43 | | - if self.distribution.tests_require: |
44 | | - self.distribution.fetch_build_eggs(self.distribution.tests_require) |
45 | | - if self.xunit_output: |
46 | | - self.distribution.fetch_build_eggs(["unittest-xml-reporting"]) |
47 | | - self.run_command("egg_info") |
48 | | - build_ext_cmd = self.reinitialize_command("build_ext") |
49 | | - build_ext_cmd.inplace = 1 |
50 | | - self.run_command("build_ext") |
51 | | - |
52 | | - # Construct a TextTestRunner directly from the unittest imported from |
53 | | - # test, which creates a TestResult that supports the 'addSkip' method. |
54 | | - # setuptools will by default create a TextTestRunner that uses the old |
55 | | - # TestResult class. |
56 | | - from test import PymongoTestRunner, test_cases, unittest |
57 | | - |
58 | | - if self.test_suite is None: |
59 | | - all_tests = unittest.defaultTestLoader.discover(self.test_module) |
60 | | - suite = unittest.TestSuite() |
61 | | - suite.addTests(sorted(test_cases(all_tests), key=lambda x: x.__module__)) |
62 | | - else: |
63 | | - suite = unittest.defaultTestLoader.loadTestsFromName(self.test_suite) |
64 | | - if self.xunit_output: |
65 | | - from test import PymongoXMLTestRunner |
66 | | - |
67 | | - runner = PymongoXMLTestRunner( |
68 | | - verbosity=2, failfast=self.failfast, output=self.xunit_output |
69 | | - ) |
70 | | - else: |
71 | | - runner = PymongoTestRunner(verbosity=2, failfast=self.failfast) |
72 | | - result = runner.run(suite) |
73 | | - sys.exit(not result.wasSuccessful()) |
74 | | - |
75 | | - |
76 | 16 | class custom_build_ext(build_ext): |
77 | 17 | """Allow C extension building to fail. |
78 | 18 |
|
@@ -189,6 +129,4 @@ def build_extension(self, ext): |
189 | 129 | ) |
190 | 130 | ext_modules = [] |
191 | 131 |
|
192 | | -setup( |
193 | | - cmdclass={"build_ext": custom_build_ext, "test": test}, ext_modules=ext_modules |
194 | | -) # type:ignore |
| 132 | +setup(cmdclass={"build_ext": custom_build_ext}, ext_modules=ext_modules) # type:ignore |
0 commit comments