-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First stab at switching to pytest, including pytest tasks
- Loading branch information
1 parent
caccb2e
commit 876d0f3
Showing
8 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
build | ||
.coverage | ||
htmlcov | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
# Dev version of Invoke | ||
invoke>=0.13.0,<2.0 | ||
# Self, for runtime/task dependencies | ||
-e . | ||
# For packaging | ||
wheel==0.24 | ||
twine==1.5 | ||
# For testing | ||
nose==1.3.0 | ||
spec>=1.4.0,<2.0 | ||
pytest-relaxed>=0.1.0,<2 | ||
pytest-cov==2.4.0 | ||
mock==1.0.1 | ||
watchdog==0.8.3 | ||
coverage==3.7.1 | ||
# For linting | ||
flake8==2.4.0 | ||
|
||
# Self, for runtime/task dependencies | ||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
Pytest-using variant of testing.py. Will eventually replace the latter. | ||
""" | ||
|
||
from invoke import Collection, task | ||
|
||
|
||
@task | ||
def test(c, verbose=True, color=True, capture='sys', opts=''): | ||
""" | ||
Run pytest with given options. | ||
:param bool verbose: | ||
Whether to run tests in verbose mode. | ||
:param bool color: | ||
Whether to request colorized output (typically only works when | ||
``verbose=True``.) | ||
:param str capture: | ||
What type of stdout/err capturing pytest should use. Defaults to | ||
``sys`` since pytest's own default, ``fd``, tends to trip up | ||
subprocesses trying to detect PTY status. Can be set to ``no`` for no | ||
capturing / useful print-debugging / etc. | ||
:param str opts: | ||
Extra runtime options to hand to ``pytest``. | ||
""" | ||
# TODO: really need better tooling around these patterns | ||
# TODO: especially the problem of wanting to be configurable, but | ||
# sometimes wanting to override one's config via kwargs; and also needing | ||
# non-None defaults in the kwargs to inform the parser (or have to | ||
# configure it explicitly...?) | ||
flags = [] | ||
if verbose: | ||
flags.append('--verbose') | ||
if color: | ||
flags.append('--color=yes') | ||
flags.append('--capture={}'.format(capture)) | ||
if opts is not None: | ||
flags.append(opts) | ||
c.run("pytest {}".format(" ".join(flags)), pty=True) | ||
|
||
|
||
@task | ||
def coverage(c): | ||
""" | ||
Run pytest with coverage enabled. | ||
Assumes the ``pytest-cov`` pytest plugin is installed. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,20 @@ | ||
from invoke import Collection, task | ||
|
||
from invocations.packaging import release | ||
from invocations.testing import test, watch_tests, coverage as coverage_ | ||
from invocations import pytest as pytests | ||
|
||
|
||
# TODO: add coverage at the Travis level as well sometime. For now this is just | ||
# to help me as I overhaul the release modules | ||
|
||
@task | ||
def coverage(c, html=True): | ||
# TODO: can we realistically make use of functools.partial for this sort of | ||
# thing? | ||
# TODO: is it best left to config option overrides (currently the usual | ||
# approach)? Is there stuff we can do to make that even easier? | ||
return coverage_(c, html=html, integration_=False) | ||
|
||
|
||
ns = Collection(release, test, watch_tests, coverage) | ||
ns = Collection(release, pytests.test, pytests.coverage) | ||
ns.configure({ | ||
'tests': { | ||
'package': 'invocations', | ||
}, | ||
'packaging': { | ||
'sign': True, | ||
'wheel': True, | ||
}, | ||
'run': { | ||
'env': { | ||
# Our ANSI color tests test against hardcoded codes appropriate for | ||
# this terminal, for now. | ||
'TERM': 'xterm-256color', | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters