Skip to content

Commit dad167f

Browse files
committed
Improve the command invoke test
- Add an option `--extension=` to test a specific extension only - Add an option `--path=` to test a specific file or folder only - Add an option `--nocov=` to disable coverage
1 parent d15d322 commit dad167f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

tasks.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,27 @@ def flake(ctx):
4949

5050

5151
@task
52-
def test(ctx, verbose=False):
52+
def test(ctx, verbose=False, nocov=False, extension=None, path=None):
53+
"""Run full or customized tests for MFR.
54+
:param ctx: the ``invoke`` context
55+
:param verbose: the flag to increase verbosity
56+
:param nocov: the flag to disable coverage
57+
:param extension: limit the tests to the given extension only
58+
:param path: limit the tests to the given path only
59+
:return: None
60+
"""
5361
flake(ctx)
54-
cmd = 'py.test --cov-report term-missing --cov mfr tests'
55-
if verbose:
56-
cmd += ' -v'
62+
# `--extension=` and `--path=` are mutually exclusive options
63+
assert not (extension and path)
64+
if path:
65+
path = '/{}'.format(path) if path else ''
66+
elif extension:
67+
path = '/extensions/{}/'.format(extension) if extension else ''
68+
else:
69+
path = ''
70+
coverage = ' --cov-report term-missing --cov mfr' if not nocov else ''
71+
verbose = '-v' if verbose else ''
72+
cmd = 'py.test{} tests{} {}'.format(coverage, path, verbose)
5773
ctx.run(cmd, pty=True)
5874

5975

0 commit comments

Comments
 (0)