diff --git a/.coveragerc b/.coveragerc index 7f5f766..5aa9b01 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,5 @@ +# -*- mode: conf -*- + [run] # only record trace data for wormhole.* source = diff --git a/src/wormhole/test/run_trial.py b/src/wormhole/test/run_trial.py new file mode 100644 index 0000000..3a8e743 --- /dev/null +++ b/src/wormhole/test/run_trial.py @@ -0,0 +1,16 @@ + +# This is a tiny helper module, to let "python -m wormhole.test.run_trial +# ARGS" does the same thing as running "trial ARGS" (unfortunately +# twisted/scripts/trial.py does not have a '__name__=="__main__"' clause). +# +# This makes it easier to run trial under coverage from tox: +# * "coverage run trial ARGS" is how you'd usually do it +# * but "trial" must be the one in tox's virtualenv +# * "coverage run `which trial` ARGS" works from a shell +# * but tox doesn't use a shell +# So use: +# "coverage run -m wormhole.test.run_trial ARGS" + +from twisted.scripts.trial import run + +run() diff --git a/tox.ini b/tox.ini index 326afa5..e23eb75 100644 --- a/tox.ini +++ b/tox.ini @@ -32,3 +32,14 @@ commands = # a script name (since "python -m twisted.scripts.trial" doesn't have a 'if # __name__ == "__main__": run()' -style clause). The script name will vary on # the platform. + +[testenv:coverage] +deps = + pyflakes >= 1.2.3 + mock + coverage + {env:EXTRA_DEPENDENCY:} +commands = + pyflakes setup.py src + wormhole --version + coverage run --branch -m wormhole.test.run_trial {posargs:wormhole}