From 71ca2b0022a10f6ba0c6647c5c68581ef9779fd0 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Mon, 23 Oct 2017 11:42:47 -0700 Subject: Remove references to test.py, including overhaul of test tasks --- tasks.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index a45b4efc..78420164 100644 --- a/tasks.py +++ b/tasks.py @@ -8,26 +8,32 @@ from invocations.packaging.release import ns as release_coll, publish from invocations.testing import count_errors -# Until we move to spec-based testing @task -def test(ctx, coverage=False, flags=""): - if "--verbose" not in flags.split(): - flags += " --verbose" - runner = "python" +def test(ctx, verbose=True, coverage=False, opts=""): + # TODO: once pytest coverage plugin works, see if there's a pytest-native + # way to handle the env stuff too, then we can remove these tasks entirely + # in favor of just "run pytest"? + if verbose: + opts += " --verbose" + runner = "pytest" if coverage: - runner = "coverage run --source=paramiko" + # Leverage how pytest can be run as 'python -m pytest', and then how + # coverage can be told to run things in that manner instead of + # expecting a literal .py file. + # TODO: get pytest's coverage plugin working, IIRC it has issues? + runner = "coverage run --source=paramiko -m pytest" # Strip SSH_AUTH_SOCK from parent env to avoid pollution by interactive # users. env = dict(os.environ) if 'SSH_AUTH_SOCK' in env: del env['SSH_AUTH_SOCK'] - cmd = "{} test.py {}".format(runner, flags) + cmd = "{} {}".format(runner, opts) ctx.run(cmd, pty=True, env=env, replace_env=True) @task -def coverage(ctx): - ctx.run("coverage run --source=paramiko test.py --verbose") +def coverage(ctx, opts=""): + return test(ctx, coverage=True, opts=opts) # Until we stop bundling docs w/ releases. Need to discover use cases first. -- cgit v1.2.1