|
10 | 10 |
|
11 | 11 |
|
12 | 12 | class SetuppyPythonTestingStep(PythonTestingStepExtensionPoint): |
13 | | - """Use `setup.py test` to test packages.""" |
| 13 | + """Use `unittest` to test packages.""" |
14 | 14 |
|
15 | 15 | def __init__(self): # noqa: D107 |
16 | 16 | super().__init__() |
17 | 17 | satisfies_version( |
18 | 18 | PythonTestingStepExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') |
19 | 19 |
|
| 20 | + def add_arguments(self, *, parser): # noqa: D102 |
| 21 | + parser.add_argument( |
| 22 | + '--unittest-args', |
| 23 | + nargs='*', metavar='*', type=str.lstrip, |
| 24 | + help='Pass arguments to Python unittests. ' |
| 25 | + 'Arguments matching other options must be prefixed by a space,\n' |
| 26 | + 'e.g. --unittest-args " --help"') |
| 27 | + |
20 | 28 | def match(self, context, env, setup_py_data): # noqa: D102 |
21 | 29 | return True |
22 | 30 |
|
23 | 31 | async def step(self, context, env, setup_py_data): # noqa: D102 |
24 | 32 | if context.args.retest_until_fail: |
25 | 33 | logger.warning( |
26 | 34 | "Ignored '--retest-until-fail' for package " |
27 | | - "'{context.pkg.name}' since 'setup.py test' does not support " |
28 | | - 'the usage'.format_map(locals())) |
| 35 | + "'{context.pkg.name}' since 'unittest' does not support the " |
| 36 | + 'usage'.format_map(locals())) |
29 | 37 |
|
30 | 38 | if context.args.retest_until_pass: |
31 | 39 | logger.warning( |
32 | 40 | "Ignored '--retest-until-pass' for package " |
33 | | - "'{context.pkg.name}' since 'setup.py test' does not support " |
34 | | - 'the usage'.format_map(locals())) |
35 | | - |
36 | | - cmd = [ |
37 | | - executable, |
38 | | - 'setup.py', 'test', |
39 | | - 'egg_info', '--egg-base', context.args.build_base, |
40 | | - ] |
| 41 | + "'{context.pkg.name}' since 'unittest' does not support the " |
| 42 | + 'usage'.format_map(locals())) |
| 43 | + |
| 44 | + cmd = [executable, '-m', 'unittest', '-v'] |
| 45 | + if context.args.unittest_args is not None: |
| 46 | + cmd += context.args.unittest_args |
41 | 47 | rc = await check_call(context, cmd, cwd=context.args.path, env=env) |
42 | 48 | if rc and rc.returncode: |
43 | 49 | return rc.returncode |
0 commit comments