Last active
November 13, 2018 04:28
-
-
Save rouge8/0fd866f8122bb4c59938fab79f658c42 to your computer and use it in GitHub Desktop.
pytest, coverage.py, multi-line set/dict/generator comprehensinos
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
[run] | |
source = test_foo | |
branch = True | |
[report] | |
show_missing = True |
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
$ tox | |
py27 installed: coverage==4.2,py==1.4.31,pytest==2.9.2 | |
py27 runtests: PYTHONHASHSEED='2822103878' | |
py27 runtests: commands[0] | coverage run -m pytest | |
===================================================== test session starts ====================================================== | |
platform darwin -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /Users/andy/tmp/coverage-bug/.tox/py27/bin/python2.7 | |
cachedir: .cache | |
rootdir: /Users/andy/tmp/coverage-bug, inifile: tox.ini | |
collected 1 items | |
test_foo.py::test_foo PASSED | |
=================================================== 1 passed in 0.01 seconds =================================================== | |
py27 runtests: commands[1] | coverage report --skip-covered -m --fail-under=100 | |
Name Stmts Miss Branch BrPart Cover Missing | |
--------------------------------------------------------- | |
test_foo.py 4 0 5 1 89% 6->exit | |
ERROR: InvocationError: '/Users/andy/tmp/coverage-bug/.tox/py27/bin/coverage report --skip-covered -m --fail-under=100' | |
py35 installed: coverage==4.2,py==1.4.31,pytest==2.9.2 | |
py35 runtests: PYTHONHASHSEED='2822103878' | |
py35 runtests: commands[0] | coverage run -m pytest | |
===================================================== test session starts ====================================================== | |
platform darwin -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /Users/andy/tmp/coverage-bug/.tox/py35/bin/python3.5 | |
cachedir: .cache | |
rootdir: /Users/andy/tmp/coverage-bug, inifile: tox.ini | |
collected 1 items | |
test_foo.py::test_foo PASSED | |
=================================================== 1 passed in 0.02 seconds =================================================== | |
py35 runtests: commands[1] | coverage report --skip-covered -m --fail-under=100 | |
Name Stmts Miss Branch BrPart Cover Missing | |
--------------------------------------------------------- | |
1 file skipped due to complete coverage. | |
___________________________________________________________ summary ____________________________________________________________ | |
ERROR: py27: commands failed | |
py35: commands succeeded | |
$ tox -- --assert=plain | |
py27 installed: coverage==4.2,py==1.4.31,pytest==2.9.2 | |
py27 runtests: PYTHONHASHSEED='296090122' | |
py27 runtests: commands[0] | coverage run -m pytest --assert=plain | |
===================================================== test session starts ====================================================== | |
platform darwin -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /Users/andy/tmp/coverage-bug/.tox/py27/bin/python2.7 | |
cachedir: .cache | |
rootdir: /Users/andy/tmp/coverage-bug, inifile: tox.ini | |
collected 1 items | |
test_foo.py::test_foo PASSED | |
=================================================== 1 passed in 0.01 seconds =================================================== | |
py27 runtests: commands[1] | coverage report --skip-covered -m --fail-under=100 | |
Name Stmts Miss Branch BrPart Cover Missing | |
--------------------------------------------------------- | |
1 file skipped due to complete coverage. | |
py35 installed: coverage==4.2,py==1.4.31,pytest==2.9.2 | |
py35 runtests: PYTHONHASHSEED='296090122' | |
py35 runtests: commands[0] | coverage run -m pytest --assert=plain | |
===================================================== test session starts ====================================================== | |
platform darwin -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /Users/andy/tmp/coverage-bug/.tox/py35/bin/python3.5 | |
cachedir: .cache | |
rootdir: /Users/andy/tmp/coverage-bug, inifile: tox.ini | |
collected 1 items | |
test_foo.py::test_foo PASSED | |
=================================================== 1 passed in 0.01 seconds =================================================== | |
py35 runtests: commands[1] | coverage report --skip-covered -m --fail-under=100 | |
Name Stmts Miss Branch BrPart Cover Missing | |
--------------------------------------------------------- | |
1 file skipped due to complete coverage. | |
___________________________________________________________ summary ____________________________________________________________ | |
py27: commands succeeded | |
py35: commands succeeded | |
congratulations :) |
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
def test_foo(): | |
# covered! | |
assert {i for i in range(10)} == {i for i in range(10)} | |
# "didn't finish the set comprehension" | |
assert {i for i in range(10)} == { | |
i for i in range(10) | |
} | |
# covered! | |
assert True | |
def test_list_comprehension(): | |
assert {i for i in range(10)} == {i for i in range(10)} | |
# "didn't finish the list comprehension" | |
assert [i for i in range(10)] == [ | |
i for i in range(10) | |
] | |
# covered! | |
assert True |
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
[pytest] | |
addopts = --strict -ra --tb=short -v | |
[tox] | |
envlist = py27,py36,py37 | |
skipsdist = true | |
skip_install = true | |
[testenv] | |
deps = | |
pytest | |
coverage | |
commands = | |
coverage run -m pytest [] | |
coverage report --skip-covered -m --fail-under=100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment