[TIP] Coverage does not cover script if py.test executes it from another directory
Christoph Buchner
bilderbuchi at phononoia.at
Wed Sep 4 14:45:32 PDT 2013
On 09/04/2013 05:03 PM, Christoph Buchner wrote:
> Ned Batchelder schrieb am 04.09.2013 16:11:
>
>> On 9/2/13 5:26 PM, Christoph Buchner wrote:
>>> On 09/02/2013 07:13 PM, Ned Batchelder wrote:
>>>> On 9/2/13 11:45 AM, Christoph Buchner wrote:
>>>>> Hi folks,
>>>>>
>>>>> I have run into an issue using py.test, pytest-cov and coverage. The
>>>>> question is also on Stackoverflow in all detail
>>>>> (http://stackoverflow.com/q/18573542/599884), but I'll also
>>>>> summarize it here:
>>>>>
>>>>> I'm writing a python script which takes command line arguments,
>>>>> working with
>>>>> some files (git repos etc).
>>>>> I've written succeeding tests with py.test putting this script
>>>>> through its
>>>>> paces (verifying it works correctly with different arguments, etc),
>>>>> executing it with subprocess.call in the tests.
>>>>>
>>>>> Now I want to analyze code coverage with coverage.py.
>>>>> Coverage, when used via the pytest-cov plugin (which has
>>>>> subprocess-handling
>>>>> already built-in/ootb), does not see/cover my script when the script is
>>>>> called from a temporary testing directory created with py.test's tmpdir
>>>>> fixture.
>>>>> Coverage does see my script when it's called in the directory it
>>>>> resides in
>>>>> (and the filename argument points to a remote path).
>>>>>
>>>>> To illustrate with a minimal example,
>>>>>> Running in directory /home/cbuchner/pytest_experiment
>>>>>> Command: ./my_script.py /tmp/pytest-52/test_10/arg_file.txt
>>>>> gets correct coverage measurement, but
>>>>>> Running in directory /tmp/pytest-52/test_11
>>>>>> Command: /home/cbuchner/pytest_experiment/my_script.py arg_file.txt
>>>>> gives "Coverage.py warning: No data was collected."
>>>>> See http://stackoverflow.com/q/18573542/599884 for full
>>>>> console output and link to the used code.
>>>>>
>>>>> In both situations, my tests pass! This is on Ubuntu, with Coverage
>>>>> 3.6,
>>>>> pytest-2.3.5, pytest-cov 1.6, all from PyPi.
>>>>>
>>>>> Questions:
>>>>> * How can I get coverage to recognize my script even if it's
>>>>> executed in
>>>>> another directory?
>>>>> * Is this a bug in coverage, or something which is just not possible
>>>>> to do?
>>>>> Would be surprised if the latter, after all, tmpdir is a stock
>>>>> mechanism of
>>>>> py.test, right?
>>>>> * If the way I did it is an inappropriate testing implementation,
>>>>> I'd be
>>>>> grateful for pointers how to "properly" coverage-test file-manipulating
>>>>> console utilities written in Python. Writing automated tests is
>>>>> pretty new
>>>>> to me, so I'm learning much and know little (yet).
>>>>>
>>>>> thanks for any pointers on this,
>>>>> best,
>>>>> Christoph
>>>>>
>>>> It's a little hard to know why it's not working without more details,
>>>> but a first thing that comes to mind is that coverage ignores code it
>>>> thinks is in the stdlib. If your script is being run from a
>>>> directory under the stdlib somehow, then that could explain it.
>>>>
>>>> Can you run "coverage debug sys" in the same context as your failing
>>>> scenario? It will show details of the configuration.
>>>>
>>>> --Ned.
>>> Yes, that's why I gave as much detail as possible (including code) in
>>> the SO answer. Didn't think of coverage debug sys, though, sorry. >.<
>>> I'm at another machine now, which exhibits the same problem.
>>> Find attached a console log (it's too long for an email I think). I
>>> don't think the paths I'm working in are under the stdlib. At the end
>>> of the log, I also ran the py.test with coverage with "-s", too, and
>>> get two additional warnings for the test_in_tmpdir.
>>> I can give a coverage debug sys output from the other, original,
>>> machine tomorrow, if still needed?
>>>
>>> Also, the code is at https://gist.github.com/bilderbuchi/6412754 (you
>>> can download a tar.gz of it), if you want to try and reproduce the
>>> problem.
>>>
>>> thanks a lot,
>>> Christoph
>> Christoph, instead of spending time reproducing your problem, I tried
>> adding a feature to coverage.py to help you diagnose it. Attached is a
>> tarball of the coverage.py kit. It adds a flag:
>>
>> coverage run --debug=notrace myprog.py etc...
>>
>> This will make coverage.py write to stderr for every file it decides not
>> to trace. Each file is listed with the reason it isn't being traced.
>> Can you try your scenario with it, and see if it gives you useful
>> information?
>>
>> --Ned.
>>
> Ned,
> thanks for the patched version! Unfortunately, I can't seem to trigger that option from a .coveragerc containing
> [run]
> debug = notrace
> when doing $py.test --cov-config=.coveragerc --cov=my_script.py tests/test_in_tmpdir.py
> (it works in coverage itself cause I see the output when using the `coverage` command. Doesn't show anything useful though due to not being modded for subprocess tracking yet)
> I have been using pytest-cov so far, which has subprocess covering out-of-the-box. I am a bit hesitant fiddling with my (working) python environment.
> Also, pytest-cov is proven to work(!) with the test_in_scriptdir test, where I get coverage, so a general malfunction there can be excluded.
>
> Reproducing my problem would be easy, though:
> * download the files, put the appropriate ones into a tests/ directory as noted in the comments within (github gists sadly don't offer subdirectories)
> * install pytest-cov if necessary
> * run the commands from the log file I attached to my previous mail
> * see if you get the same problem with the test_in_tmpdir.
>
> Anything further I can do to diagnose this?
> I can later try modifying my python install according to the guide to make vanilla coverage work, to be able to use your patched version to reproduce.
>
> thanks,
> Christoph
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
OK, after some further investigations on my home system, where I have
enticed vanilla coverage to cover subprocesses (going the .pth route),
with your patched version, it finds the script file for both tests, but
doesn't cover it in case of test_tmpdir. See attached logfile
console_log2.txt.
best,
many thanks for any help,
christoph
-------------- next part --------------
pytest_experiment$ cat .coveragerc
[run]
debug = notrace
parallel = true
pytest_experiment$ coverage debug sys
-- sys ----------------------------------------
version: 3.6.1a1
coverage: /home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/__init__.pyc
cover_dir: /home/bilderbuchi/.local/lib/python2.7/site-packages/coverage
pylib_dirs: /usr/lib/python2.7
tracer: CTracer
config_files: .coveragerc
configs_read: .coveragerc
data_path: /media/windata/Visuals/Coding/pytest_experiment/.coverage
python: 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3]
platform: Linux-3.8.0-29-generic-x86_64-with-Ubuntu-13.04-raring
implementation: CPython
executable: /usr/bin/python
cwd: /media/windata/Visuals/Coding/pytest_experiment
path: /home/bilderbuchi/.local/bin
/usr/local/lib/python2.7/dist-packages/times-0.4-py2.7.egg
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/home/bilderbuchi/.local/lib/python2.7/site-packages
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gst-0.10
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode
environment: COVERAGE_PROCESS_START = .coveragerc
################################################################################
################################################################################
1st test: 100% coverage on my_script shows that subprocess coverage works:
pytest_experiment$ coverage erase
pytest_experiment$ coverage run --source . -m py.test tests/test_in_scriptdir.py
Not tracing '/usr/lib/python2.7/threading.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/execfile.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_apipkg.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/posixpath.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/backward.py': falls outside the --source trees
Not tracing '<exec_function>': not a real filename
Not tracing '/usr/local/lib/python2.7/dist-packages/py/test.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/pytest.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/__init__.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/core.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/hookspec.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/UserDict.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/config.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_std.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/inspect.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/code.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_builtin.py': falls outside the --source trees
Not tracing '<string>': not a real filename
Not tracing '/usr/lib/python2.7/repr.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/mark.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/main.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/local.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/common.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/re.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/sre_compile.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/sre_parse.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/abc.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/_weakrefset.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/terminal.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/runner.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/python.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/monkeypatch.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/pdb.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/unittest.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/capture.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/skipping.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/tmpdir.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/recwarn.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/pastebin.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/helpconfig.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/nose.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/capture.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/tempfile.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/io.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/__init__.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/util.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/genscript.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/junitxml.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_xmlgen.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/resultlog.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/doctest.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/genericpath.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/dist-packages/pkg_resources.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/pytest_cov.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/os.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/random.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/optparse.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/ast.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/oldinterpret.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/__init__.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/transformer.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/ast.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/consts.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/copy_reg.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/symbol.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/visitor.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/pycodegen.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/syntax.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/pyassem.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/misc.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/future.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/symbols.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/newinterpret.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/saferepr.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/source.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/string.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_error.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/linecache.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/bisect.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/tokenize.py': falls outside the --source trees
Not tracing '<assertion interpretation>': not a real filename
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/terminalwriter.py': falls outside the --source trees
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 1 items
tests/test_in_scriptdir.py .
==================================================== 1 passed in 0.11 seconds =====================================================
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/control.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/collector.py': falls outside the --source trees
pytest_experiment$ coverage combine
pytest_experiment$ coverage report
Name Stmts Miss Cover
----------------------------------------------------------------------------
/etc/python2.7/sitecustomize 5 2 60%
/home/bilderbuchi/.local/bin/coverage 5 0 100%
/usr/local/lib/python2.7/dist-packages/py/_code/code 518 516 1%
/usr/local/lib/python2.7/dist-packages/py/_error 50 47 6%
/usr/local/lib/python2.7/dist-packages/py/_path/common 233 220 6%
/usr/local/lib/python2.7/dist-packages/py/_path/local 588 573 3%
/usr/share/pyshared/apport_python_hook 108 98 9%
/usr/share/pyshared/mpl_toolkits/__init__ 4 2 50%
/usr/share/pyshared/pkg_resources 1384 647 53%
/usr/share/pyshared/zope/__init__ 6 3 50%
my_script 3 0 100%
tests/conftest 7 0 100%
tests/test_in_scriptdir 11 0 100%
tests/test_in_tmpdir 9 0 100%
----------------------------------------------------------------------------
TOTAL 2931 2108 28%
################################################################################
################################################################################
2nd test: no coverage on my_script at the end
pytest_experiment$ coverage erase
pytest_experiment$ coverage run --source . -m py.test tests/test_in_tmpdir.py
Not tracing '/usr/lib/python2.7/threading.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/execfile.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_apipkg.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/posixpath.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/backward.py': falls outside the --source trees
Not tracing '<exec_function>': not a real filename
Not tracing '/usr/local/lib/python2.7/dist-packages/py/test.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/pytest.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/__init__.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/core.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/hookspec.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/UserDict.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/config.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_std.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/inspect.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/code.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_builtin.py': falls outside the --source trees
Not tracing '<string>': not a real filename
Not tracing '/usr/lib/python2.7/repr.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/mark.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/main.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/local.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_path/common.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/re.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/sre_compile.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/sre_parse.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/abc.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/_weakrefset.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/terminal.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/runner.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/python.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/monkeypatch.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/pdb.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/unittest.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/capture.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/skipping.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/tmpdir.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/recwarn.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/pastebin.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/helpconfig.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/nose.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/__init__.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/capture.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/tempfile.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/io.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/__init__.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/util.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/genscript.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/junitxml.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_xmlgen.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/resultlog.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/doctest.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/genericpath.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/dist-packages/pkg_resources.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/pytest_cov.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/os.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/random.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/optparse.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/ast.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/oldinterpret.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/__init__.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/transformer.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/ast.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/consts.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/copy_reg.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/symbol.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/visitor.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/pycodegen.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/syntax.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/pyassem.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/misc.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/future.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/compiler/symbols.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/newinterpret.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/saferepr.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_code/source.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/string.py': falls outside the --source trees
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_error.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/linecache.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/bisect.py': falls outside the --source trees
Not tracing '/usr/lib/python2.7/tokenize.py': falls outside the --source trees
Not tracing '<assertion interpretation>': not a real filename
Not tracing '/usr/local/lib/python2.7/dist-packages/py/_io/terminalwriter.py': falls outside the --source trees
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 1 items
tests/test_in_tmpdir.py .
==================================================== 1 passed in 0.10 seconds =====================================================
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/control.py': falls outside the --source trees
Not tracing '/home/bilderbuchi/.local/lib/python2.7/site-packages/coverage/collector.py': falls outside the --source trees
pytest_experiment$ coverage combine
pytest_experiment$ coverage report
Name Stmts Miss Cover
----------------------------------------------------------------------------
/etc/python2.7/sitecustomize 5 2 60%
/home/bilderbuchi/.local/bin/coverage 5 0 100%
/usr/local/lib/python2.7/dist-packages/py/_code/code 518 516 1%
/usr/local/lib/python2.7/dist-packages/py/_error 50 47 6%
/usr/local/lib/python2.7/dist-packages/py/_path/common 233 220 6%
/usr/local/lib/python2.7/dist-packages/py/_path/local 588 573 3%
/usr/share/pyshared/apport_python_hook 108 98 9%
/usr/share/pyshared/mpl_toolkits/__init__ 4 2 50%
/usr/share/pyshared/pkg_resources 1384 647 53%
/usr/share/pyshared/zope/__init__ 6 3 50%
my_script 3 3 0%
tests/conftest 7 0 100%
tests/test_in_tmpdir 9 0 100%
----------------------------------------------------------------------------
TOTAL 2920 2111 28%
################################################################################
################################################################################
going on with testing my actual usage, i.e. py.test with pytest-cov:
pytest_experiment$ rm .coverage.*
pytest_experiment$ py.test --cov=my_script.py tests/test_in_scriptdir.py
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 1 items
tests/test_in_scriptdir.py .
----------------------------------------- coverage: platform linux2, python 2.7.4-final-0 -----------------------------------------
Name Stmts Miss Cover
----------------------------------------------------------------------------------------
/home/bilderbuchi/.local/lib/python2.7/site-packages/cov_core_init 19 3 84%
my_script 3 0 100%
----------------------------------------------------------------------------------------
TOTAL 22 3 86%
==================================================== 1 passed in 0.11 seconds =====================================================
pytest_experiment$ rm .coverage.*
pytest_experiment$ py.test --cov=my_script.py tests/test_in_tmpdir.py
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 1 items
tests/test_in_tmpdir.py .Coverage.py warning: No data was collected.
----------------------------------------- coverage: platform linux2, python 2.7.4-final-0 -----------------------------------------
Name Stmts Miss Cover
---------------------------
==================================================== 1 passed in 0.09 seconds =====================================================
More information about the testing-in-python
mailing list