Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No coverage data is collected for installed package when py.test is run in the project's root directory #98

Closed
jck opened this issue Nov 4, 2015 · 39 comments

Comments

@jck
Copy link

jck commented Nov 4, 2015

If I have a package(and pytest-cov) installed in a virtualenv, and I run pytest-cov from the project's root directory(which has the package folder), then no coverage data is collected.

@ionelmc
Copy link
Member

ionelmc commented Nov 4, 2015

Hey, I need more details to figure out what's going on:

  • how do you run pytest
  • pytest configuration (tox.ini/setup.cfg/pytest.ini)
  • coverage configuration (.coveragerc)

@jck
Copy link
Author

jck commented Nov 4, 2015

Steps to reproduce the bug:

~/t/mylib git:master ❯❯❯ pip freeze                                                                                                                                                          ✱ ◼ v:7573fdbc6e567b2 
coverage==4.0.2
mylib==0.1.0
py==1.4.30
pytest==2.8.2
pytest-cov==2.2.0
wheel==0.24.0
~/t/mylib git:master ❮❮❮ py.test --cov mylib                                                                                                                                                 ✱ ◼ v:7573fdbc6e567b2 
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.5.0, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/jck/tmp/mylib, inifile: 
plugins: cov-2.2.0
collected 1 items 

tests/test_mylib.py .Coverage.py warning: No data was collected.

---------------------------------------------------------------------------------- coverage: platform linux, python 3.5.0-final-0 ----------------------------------------------------------------------------------
Name                Stmts   Miss  Cover
---------------------------------------
mylib/__init__.py       7      7     0%

============================================================================================= 1 passed in 0.01 seconds =============================================================================================
~/t/mylib git:master ❯❯❯ cd tests                                                                                                                                                            ✱ ◼ v:7573fdbc6e567b2 
~/t/m/tests git:master ❮❮❮ py.test --cov mylib                                                                                                                                               ✱ ◼ v:7573fdbc6e567b2 
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.5.0, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/jck/tmp/mylib, inifile: 
plugins: cov-2.2.0
collected 1 items 

test_mylib.py .
---------------------------------------------------------------------------------- coverage: platform linux, python 3.5.0-final-0 ----------------------------------------------------------------------------------
Name                                                                                               Stmts   Miss  Cover
----------------------------------------------------------------------------------------------------------------------
/home/jck/.local/share/virtualenvs/7573fdbc6e567b2/lib/python3.5/site-packages/mylib/__init__.py       7      2    71%

============================================================================================= 1 passed in 0.01 seconds =============================================================================================

@jck jck closed this as completed Nov 4, 2015
@jck jck reopened this Nov 4, 2015
@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

Seems to be working as expected for me:

============================================================================================================ test session starts ============================================================================================================
platform linux -- Python 3.5.0, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/ionel/sandbox/mylib, inifile:
plugins: cov-2.2.0
collected 1 items

tests/test_mylib.py .
---------------------------------------------------------------------------------------------- coverage: platform linux, python 3.5.0-final-0 -----------------------------------------------------------------------------------------------
Name                                                                  Stmts   Miss  Cover
-----------------------------------------------------------------------------------------
.ve/lib/python3.5/codecs.py                                             398    389     2%
.ve/lib/python3.5/encodings/__init__.py                                  65     54    17%
.ve/lib/python3.5/site-packages/_pytest/_argcomplete.py                  35     34     3%
.ve/lib/python3.5/site-packages/_pytest/assertion/__init__.py            81     45    44%
.ve/lib/python3.5/site-packages/_pytest/assertion/newinterpret.py       268    200    25%
.ve/lib/python3.5/site-packages/_pytest/assertion/reinterpret.py         36     13    64%
.ve/lib/python3.5/site-packages/_pytest/assertion/rewrite.py            523    373    29%
.ve/lib/python3.5/site-packages/_pytest/assertion/util.py               222    202     9%
.ve/lib/python3.5/site-packages/_pytest/cacheprovider.py                137    103    25%
.ve/lib/python3.5/site-packages/_pytest/capture.py                      308    250    19%
.ve/lib/python3.5/site-packages/_pytest/config.py                       759    632    17%
.ve/lib/python3.5/site-packages/_pytest/doctest.py                      146    142     3%
.ve/lib/python3.5/site-packages/_pytest/genscript.py                     81     78     4%
.ve/lib/python3.5/site-packages/_pytest/helpconfig.py                    95     87     8%
.ve/lib/python3.5/site-packages/_pytest/junitxml.py                     178    176     1%
.ve/lib/python3.5/site-packages/_pytest/main.py                         511    292    43%
.ve/lib/python3.5/site-packages/_pytest/mark.py                         160    152     5%
.ve/lib/python3.5/site-packages/_pytest/monkeypatch.py                  115    103    10%
.ve/lib/python3.5/site-packages/_pytest/nose.py                          42     28    33%
.ve/lib/python3.5/site-packages/_pytest/pastebin.py                      58     57     2%
.ve/lib/python3.5/site-packages/_pytest/pdb.py                           78     71     9%
.ve/lib/python3.5/site-packages/_pytest/python.py                      1390   1073    23%
.ve/lib/python3.5/site-packages/_pytest/resultlog.py                     84     82     2%
.ve/lib/python3.5/site-packages/_pytest/runner.py                       333    223    33%
.ve/lib/python3.5/site-packages/_pytest/skipping.py                     212    182    14%
.ve/lib/python3.5/site-packages/_pytest/terminal.py                     439    325    26%
.ve/lib/python3.5/site-packages/_pytest/tmpdir.py                        62     55    11%
.ve/lib/python3.5/site-packages/_pytest/unittest.py                     144    137     5%
.ve/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py     413    277    33%
.ve/lib/python3.5/site-packages/mylib/__init__.py                         7      2    71%
.ve/lib/python3.5/site-packages/pkg_resources/__init__.py              1607   1604     1%
.ve/lib/python3.5/site-packages/py/_apipkg.py                           138    109    21%
.ve/lib/python3.5/site-packages/py/_builtin.py                          188    177     6%
.ve/lib/python3.5/site-packages/py/_code/code.py                        523    498     5%
.ve/lib/python3.5/site-packages/py/_code/source.py                      285    165    42%
.ve/lib/python3.5/site-packages/py/_error.py                             50     45    10%
.ve/lib/python3.5/site-packages/py/_io/saferepr.py                       49     28    43%
.ve/lib/python3.5/site-packages/py/_io/terminalwriter.py                234    151    35%
.ve/lib/python3.5/site-packages/py/_path/common.py                      244    153    37%
.ve/lib/python3.5/site-packages/py/_path/local.py                       628    490    22%
.ve/lib/python3.5/site-packages/py/_std.py                               11      5    55%
.ve/lib/python3.5/site-packages/py/_xmlgen.py                           170    168     1%
.ve/lib/python3.5/site-packages/pytest_cov/engine.py                    156    145     7%
.ve/lib/python3.5/site-packages/pytest_cov/plugin.py                    101     90    11%
tests/test_mylib.py                                                       4      0   100%
-----------------------------------------------------------------------------------------
TOTAL                                                                 11768   9665    18%

========================================================================================================= 1 passed in 1.16 seconds ==========================================================================================================

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

Note the .ve/lib/python3.5/site-packages/mylib/__init__.py 7 2 71%

I think what you need here is a path mapping in .coveragerc

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

To be honest I have never figured out how to get that damn mapping to work (https://coverage.readthedocs.org/en/latest/config.html#paths) so I always have two envs, one for normal runs and one for coverage runs (where something alone the lines of pip install -e . happens - editable installs). See this.

@jck
Copy link
Author

jck commented Nov 5, 2015

What was your PWD and command from the output you posted?

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015 via email

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

You also appear to have the expected result:

~/t/m/tests git:master ❮❮❮ py.test --cov mylib                                                                                                                                                 ◼ v:7573fdbc6e567b2 
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.5.0, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/jck/tmp/mylib, inifile: 
plugins: cov-2.2.0
collected 1 items 

test_mylib.py .
---------------------------------------------------------------------------------- coverage: platform linux, python 3.5.0-final-0 ----------------------------------------------------------------------------------
Name                                                                                               Stmts   Miss  Cover
----------------------------------------------------------------------------------------------------------------------
/home/jck/.local/share/virtualenvs/7573fdbc6e567b2/lib/python3.5/site-packages/mylib/__init__.py       7      2    71%

============================================================================================= 1 passed in 0.01 seconds =============================================================================================

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

I think this can be closed. I don't think there's a way to solve this in pytest-cov. Maybe report issue with paths mapping at https://bitbucket.org/ned/coveragepy/ ?

@ionelmc ionelmc closed this as completed Nov 5, 2015
@jck
Copy link
Author

jck commented Nov 5, 2015

I have the expected result when my pwd is the tests subdirectory.

When I run from the project root, I get nothing.

@ionelmc ionelmc reopened this Nov 5, 2015
@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

Ok, and if you run just py.test --cov (no package name) in the root?

@jck
Copy link
Author

jck commented Nov 5, 2015

aah, I get the same results as you in that case.

@ionelmc
Copy link
Member

ionelmc commented Nov 5, 2015

Ok, so not a pytest-cov issue yes? :)

@ionelmc ionelmc closed this as completed Nov 5, 2015
michael-afanasiev pushed a commit to michael-afanasiev/csemlib that referenced this issue Apr 9, 2016
Had a problem where coverage wasn't being executed properly, and solved
it with the solution at:
pytest-dev/pytest-cov#98.
nazavode added a commit to nazavode/automaton that referenced this issue Jan 20, 2017
When running under Travis, I stumbled upon this issue:
pytest-dev/pytest-cov#98
Editable install seems to fix.
@Natim
Copy link

Natim commented Aug 4, 2017

When having the issue with tox, I turned usedevelop = True and it fixed the issue.

@normanpilusa
Copy link

I had the same problem. I had a wrong folder name here:
COV = coverage.coverage(branch=True, include='my_Folder/')

ericof added a commit to websauna/websauna.j2secret that referenced this issue Oct 16, 2017
@Midnighter
Copy link

Midnighter commented Jan 9, 2018

Another option with tox is to set the PYTHONPATH in tox.ini:

[testenv]
setenv =
    PYTHONPATH = {toxinidir}
commands =
    pytest --cov=<your package>
    - codecov

@dmtucker
Copy link

dmtucker commented Feb 8, 2018

When having the issue with tox, I turned usedevelop = True and it fixed the issue.

This does not appear to work with an intermediate src/ directory.

edit: Actually, nevermind... I started with a fresh clone and was not able to reproduce this. FWIW, usedevelop does not seem necessary with an intermediate src/ directory, but it doesn't break anything for me.

@ionelmc
Copy link
Member

ionelmc commented Feb 8, 2018

@dmtucker please open an issue and post some details to help reproduce your problem.

@geoff-coppertop
Copy link

More annoying than anything I see "Coverage.py warning: No data was collected. (no-data-collected)" in the command output when I run "make test" from the root of the following repo https://github.com/geoff-coppertop/python-hw-railroad

I'm still getting the coverage data in the reports directory.

@Midnighter
Copy link

Midnighter commented Apr 19, 2018

@geoff-coppertop For the source path I would define that with tox. I'm referring to this line. I'd rather write in testenv section:

[testenv]
commands =
    pytest --cov={envsitepackagesdir}/hw_railroad

@theRealSuperMario
Copy link

@geoff-coppertop For the source path I would define that with tox. I'm referring to this line. I'd rather write in testenv section:

[testenv]
commands =
    pytest --cov={envsitepackagesdir}/hw_railroad

that solved it for me

@haibin
Copy link

haibin commented Jan 4, 2019

I got the same issue and adding a tests/init.py helped. Refer to http://thomas-cokelaer.info/blog/2017/01/pytest-cov-collects-no-data-on-travis/

nazavode added a commit to nazavode/automaton that referenced this issue Jan 23, 2019
# This is the 1st commit message:
Import latest version

# This is the commit message #2:

Added PyCharm stuff to ignore file.

# This is the commit message #3:

Added package skeleton.

# This is the commit message #4:

Updated license, now Apache 2.0.

# This is the commit message #5:

Changed README to RST format.

# This is the commit message #6:

Added requirements stuff.

# This is the commit message #7:

Added misc utility scripts.

# This is the commit message #8:

Added tox draft. To be tested.

# This is the commit message #9:

Added tox draft. To be tested.

# This is the commit message #10:

Added test skeleton.

# This is the commit message #11:

Added source skeleton.

# This is the commit message #12:

Added version info.

# This is the commit message #13:

Renamed test->tests to match directory naming.

# This is the commit message #14:

Added setup.py.

# This is the commit message #15:

Added fixture file. Misc, minor changes.

# This is the commit message #16:

Added missing config files.

# This is the commit message #17:

Added misc drafts.

# This is the commit message #18:

Added Sphinx stuff. To be reviewed.

# This is the commit message #19:

Added misc drafts.

# This is the commit message #20:

Fixed Event class.

# This is the commit message #21:

Added misc drafts.

# This is the commit message #22:

Fixed Sphinx configuration.

# This is the commit message #23:

Added missing flake8 requirements file.

# This is the commit message #24:

Fixed misc setup files.

# This is the commit message #25:

Fixed linting.

# This is the commit message #26:

Added TravisCI config file.

# This is the commit message #27:

Added service badges to README.

# This is the commit message #28:

Added TODO tag to automaton meta to break pylint.

...I needed a forcing reminder.
# This is the commit message #29:

Working on tdd, test failure is wanted.

# This is the commit message #30:

Fixed TravisCI badge.

Fixed the TravisCI badge, the SVG link pointed to another project (Zirkon by @simone-campagna from which the snippet was stolen).
# This is the commit message #31:

Tests added. Still working on TDD.

# This is the commit message #32:

Removed HTTPS badge retrieval (Read The Docs).

# This is the commit message #33:

Added exceptions file.

# This is the commit message #34:

Added static property util.

# This is the commit message #35:

API change: a base class is now provided instead of a (less neat) metaclass.

# This is the commit message #36:

API change: fixed metaclass mechanics for the new API.

# This is the commit message #37:

Fixed tests for the new API.

# This is the commit message #38:

Event: it was almost useless, changed from a class to a namedtuple.

# This is the commit message #39:

Added basic transition logic.

# This is the commit message #40:

Added license.

# This is the commit message #41:

Finalized transition mechanics.

# This is the commit message #42:

Removed unused import.

# This is the commit message #43:

Cosmetics.

# This is the commit message #44:

Added stubs for connection check.

# This is the commit message #45:

Addes proper tests for connection check.

# This is the commit message #46:

Removed class properties: they are evil while playing with metaclasses.
Added state graph connection check.
Added tests.

# This is the commit message #47:

Added class methods tests.

# This is the commit message #48:

Fixed linting.

# This is the commit message #49:

Fixed linting and docstrings.

# This is the commit message #50:

Fixed documentation structure and generated apidoc.

# This is the commit message #51:

Added todo file.

# This is the commit message #52:

Improved readme.

# This is the commit message #53:

Fixed doctests while executed in Sphinx.

# This is the commit message #54:

Fixed doctests while executed in Sphinx.

# This is the commit message #55:

Added empty definition test.

# This is the commit message #56:

Working on README.

# This is the commit message #57:

Working on README.

# This is the commit message #58:

Fixed rst syntax.
# This is the commit message #59:

Added event methods to automaton instances.

# This is the commit message #60:

Moved event interface methods at class level.

# This is the commit message #61:

Fixed linting.

# This is the commit message #62:

Fixed linting.

# This is the commit message #63:

API change: Event is now a descriptor, it acts as a class property and as a bound method at the same time (just like SQLAlchemy's Column attributes).

# This is the commit message #64:

Cosmetics.

# This is the commit message #65:

API change: removed state setter, it was reduntant.

# This is the commit message #66:

Fixed linting.

# This is the commit message #67:

Working on README.

# This is the commit message #68:

Working on README.

# This is the commit message #69:

Working on README.

# This is the commit message #70:

Fixed link.
# This is the commit message #71:

Working on README.

# This is the commit message #72:

Working on README.

# This is the commit message #73:

Fixed RST syntax.
# This is the commit message #74:

Fixed RST syntax.
# This is the commit message #75:

Added Event binding test.

# This is the commit message #76:

Updated TODOs.
# This is the commit message #77:

Removed TODO file, corresponding issues opened.
# This is the commit message #78:

Cached event delegates.

# This is the commit message #79:

Event made a read-only data descriptor.

# This is the commit message #80:

Tests fixtured.

# This is the commit message #81:

Accepting (final) states support.

# This is the commit message #82:

Fixed linting.

# This is the commit message #83:

Fixed coverage.

# This is the commit message #84:

Added descriptor test.

# This is the commit message #85:

Replaced the delegate class with a closure.

# This is the commit message #86:

Fixed setup.py, now PyPi compliant.

# This is the commit message #87:

Fixed setup.py, now PyPi compliant.

# This is the commit message #88:

Added (failing) tests for sink states.

# This is the commit message #89:

Added sink states. Closes #5.

# This is the commit message #90:

Version 0.2.0.

# This is the commit message #91:

Added loop automaton test.

# This is the commit message #92:

Moved graph stuff to a file on its own.

# This is the commit message #93:

Added tricky graph test.

# This is the commit message #94:

Small fixes on docs.

# This is the commit message #95:

Fixed Travis badge after username change.
# This is the commit message #96:

Fixed Travis badge after username change.
# This is the commit message #97:

Fixed package metadata after username change.

# This is the commit message #98:

Fixed documentation.

# This is the commit message #99:

cleaning up setup stuff, previous approach was the usual pip+distutils mess

# This is the commit message #100:

packaging and testing machinery cleanup

 * fixed requirement files and setup.py following PPA guidelines
 * streamlined tox.ini
 * removed a lot of useless crap

# This is the commit message #101:

added local development virtualenv to ignores

# This is the commit message #102:

fixed missing import

# This is the commit message #103:

fixed travis config and moved to codecov

# This is the commit message #104:

fixed glitch in travis file

# This is the commit message #105:

fixed pytest-cov nasty issue

When running under Travis, I stumbled upon this issue:
pytest-dev/pytest-cov#98
Editable install seems to fix.

# This is the commit message #106:

First attempt in having tox driving Travis (including codecov upload)

# This is the commit message #107:

Fixed tox-travis env key

# This is the commit message #108:

Fixed tox-travis using the 'python' key in [travis] section

# This is the commit message #109:

Fixing again pytest-cov 'no data was collected' issue

# This is the commit message #110:

Trying to fix pytest-cov issue with explicit editable install in codecov section

# This is the commit message #111:

Comments errata corrige

# This is the commit message #112:

Added install deps to linting, it was complaining about missing imports

# This is the commit message #113:

Removed all homebrewed graph stuff, switched to networkx

# This is the commit message #114:

Fixed documentation

# This is the commit message #115:

Updated project virtualenv dir name in gitignore

# This is the commit message #116:

Added test for inbound events

# This is the commit message #117:

Fixed glitch

# This is the commit message #118:

Fixed edges generator in Event

# This is the commit message #119:

Added methods to retrieve a subgraph cut (inbound and outbound)

# This is the commit message #120:

Linting

# This is the commit message #121:

Fixed doctests

# This is the commit message #122:

Fixed a lot of TODOs and linting

# This is the commit message #123:

Removed redundant exceptions file

# This is the commit message #124:

Draft for formatting stuff, needs streamlining

# This is the commit message #125:

Tabulation function cleanup

# This is the commit message #126:

Fancy tests

# This is the commit message #127:

Added tests for transition table formatting

Still missing a lot of coverage.
# This is the commit message #128:

Updated coverage badge
# This is the commit message #129:

Add Codacy badge
# This is the commit message #130:

Moved Codacy Badge
# This is the commit message #131:

Enabled doctests

# This is the commit message #132:

Updated ReadTheDocs badge
# This is the commit message #133:

Bump version: 0.2.0 → 1.0.0

# This is the commit message #134:

Added PyPI badge to README.rst
# This is the commit message #135:

Generator streamlining and added missing docstrings

Squashed commit of the following:

commit e95b94c35a396c86800b47360c9220747ffb6012
Author: Federico Ficarelli <federico.ficarelli@gmail.com>
Date:   Fri Jan 27 23:20:57 2017 +0100

    WIP

commit bf39b4995c80e426fec600984ecaeba9fa0caeff
Author: Federico Ficarelli <federico.ficarelli@gmail.com>
Date:   Fri Jan 27 22:58:23 2017 +0100

    WIP

commit 162ee37db66c33e40448697ffed5e94c26605c97
Author: Federico Ficarelli <federico.ficarelli@gmail.com>
Date:   Fri Jan 27 20:30:35 2017 +0100

    WIP

commit caf59df89ed82a22ce1d4464f0cdb4547677d742
Author: Federico Ficarelli <federico.ficarelli@gmail.com>
Date:   Fri Jan 27 20:28:37 2017 +0100

    WIP

commit 73c5d4a5f7e62150897bbec7ec18a9ac48388d77
Author: Federico Ficarelli <federico.ficarelli@gmail.com>
Date:   Fri Jan 27 20:21:37 2017 +0100

    WIP

# This is the commit message #136:

Fixed plantuml function parameters, tests and misc docstrings

# This is the commit message #137:

Added traversal tests for formatting fuctions

# This is the commit message #138:

Added changelog to README.rst
# This is the commit message #139:

Minor cosmetic changes to README.rst
# This is the commit message #140:

Bump version: 1.0.0 → 1.1.0

# This is the commit message #141:

Refactored formatting stuff, added initial support for custom 'format()' specifiers

# This is the commit message #142:

Fixed __format__ for both instances and Automaton subclasses

# This is the commit message #143:

Added auto completion of class docstring with formatted automaton representation

# This is the commit message #144:

Fixed cosmetics in README.rst
# This is the commit message #145:

Removed package, the whole library now lives in a single module file

# This is the commit message #146:

Updated changelog in README

# This is the commit message #147:

Bump version: 1.1.0 → 1.2.0

# This is the commit message #148:

Fixed minor README glitches

# This is the commit message #149:

Uncovered severe issue to packaging

As explained here https://hynek.me/articles/testing-packaging/ and here
pyca/cryptography@c62a78c
the problem was that we were running tests *against the source package, not the
installed one*.

# This is the commit message #150:

Fixed dist and tox - now running tests against installed module

# This is the commit message #151:

Updated changelog

# This is the commit message #152:

Fixed bumpversion and Sphynx

# This is the commit message #153:

Bump version: 1.2.0 → 1.2.1

# This is the commit message #154:

Updated changelog in README.rst

# This is the commit message #155:

Updated changelog with next release TODOs

# This is the commit message #156:

Tests cleanup

# This is the commit message #157:

Added failing tests for next fixes to be done

# This is the commit message #158:

Added xfailing tests for new features, xfailed others

# This is the commit message #159:

Requirements cleanup

# This is the commit message #160:

Added descriptor proxy to access all Event stuff from automaton instances

# This is the commit message #161:

Added docstring to proxy type

# This is the commit message #162:

Fixed Sphinx internal references

# This is the commit message #163:

Added support for initial event startup

# This is the commit message #164:

Typo

# This is the commit message #165:

Changelog updated

# This is the commit message #166:

Fixed README.rst glitches

# This is the commit message #167:

Fixed Sphinx glitches

# This is the commit message #168:

Improving README.rst

# This is the commit message #169:

Improving README.rst

# This is the commit message #170:

Improving README.rst

# This is the commit message #171:

Improving README.rst

# This is the commit message #172:

Updated README.rst with external link to images
# This is the commit message #173:

Fixed changelog in README.rst

# This is the commit message #174:

Bump version: 1.2.1 → 1.3.0

# This is the commit message #175:

Fixed README.rst for pypi rendering

# This is the commit message #176:

Bump version: 1.3.0 → 1.3.1
smheidrich added a commit to smheidrich/pathlib-fs that referenced this issue Mar 16, 2019
@rogerdahl
Copy link

I have an omit = section in my .coveragerc with around 20 filters. If I add a filter of */.* to exclude dot-files and dot-dirs, I start getting the "Coverage.py warning: No data was collected" warnings.

omit =
  # All dot-files and dirs
  */.*
  ...

@Midnighter
Copy link

Midnighter commented Jun 20, 2019

I have finished up a minimal Python package repo just yesterday. It demonstrates how to combine tox with an installed package from src/ to get coverage and successful reports at codecov.io, too.

You can find the full-implementation branch here.

In order to get codecov.io working, I had to configure the following section.

[coverage:paths]
source =
    src/demo
    */site-packages/demo

where demo is the name of the package.

@ionelmc
Copy link
Member

ionelmc commented Jul 5, 2019

@rogerdahl if Midnighter didn't address your problem already it would be best to open a new issue for your problem (with a reproducer and such).

@rogerdahl
Copy link

Thanks, @ionelmc. My issue is resolved. I just added it as a datapoint for others who might have this issue.

@bsergean
Copy link

I spent a long time troubleshooting that problem (on travis), and I fixed it by adding an init.py file in my tests directory. That was it ...

@ttruongatl
Copy link

adding __init__.py into test folder works fine for me.

@joaomcteixeira
Copy link

Just to add on the discussion:
I can have nice coverage report running mannually:

pytest --cov=src --cov-append --cov-report=term-missing --junitxml 1.xml tests/

but when in tox I had to add the

usedevelop = true

line to [testenv]. With this option the output was the same results as running manually.

It there any fault added to this strategy? For example, not testing a proper installation?

tox.ini:

[coverage:paths]                                                                
source =                                                                        
    src                                                                         
                                                                                
[coverage:run]                                                                  
branch = true                                                                   
source =                                                                        
    src                                                                         
parallel = true                                                                 
                                                                                
[coverage:report]                                                               
show_missing = true                                                             
precision = 2                                                                   
omit = *migrations*                                                             
                                                                                
# https://hypothesis.readthedocs.io/en/latest/index.html                        
[testenv]                                                                       
wheel = true                                                                    
usedevelop = true                                                               
passenv = *                                                                     
deps =                                                                          
    pytest                                                                      
    pytest-travis-fold                                                          
    pytest-cov                                                                  
    hypothesis                                                                  
commands =                                                                      
    pytest --cov --cov-append --cov-report=term-missing --junitxml {toxworkdir}/junit.{envname}.xml {posargs} tests/

@dmtucker
Copy link

dmtucker commented Oct 4, 2019

It there any fault added to this strategy?

Yes, it makes it slightly more likely that breaking the build/install would not be caught (because the package and its deps are not reinstalled for every Tox run).

@joaomcteixeira
Copy link

joaomcteixeira commented Oct 5, 2019

Hi @dmtucker
Thanks for your reply, you indeed confirmed my suspicions (I am still new to Tox). After my comment, I went on reading more and I actually understood the strategy (and syntax) of @ionelmc tox.ini at master branch config duplicating the tests with usedevelop on and off, I guess that's what he meant in his comment above.

Thanks for the explanation

@dmmfll
Copy link

dmmfll commented Nov 12, 2019

usedevelop = false in tox.ini

I sometimes have this issue when I run tox -p auto.

The py38 version outputs a warning "warning: No data was collected" yet there is no warning for py36 or py37.

(I am new to tox and was looking for a solution which is what brought me here.)

Though it takes longer tox -r -p auto does not output the warning. Subsequent runs of tox -p auto then no longer output the warning.

I probably have done something unconventional along the way.

@eric-wieser
Copy link

eric-wieser commented Aug 12, 2021

It turns out that the [paths] solution described above only works if you have multiple coverage runs that you later combine. If you only have a single run, this seems to fix the problem:

mv .coverage .coverage.hack  # I can't combine it without renaming
coverage combine
coverage report

@chrisinmtown
Copy link

chrisinmtown commented Jan 5, 2022

I got the same issue and adding a tests/init.py helped. Refer to http://thomas-cokelaer.info/blog/2017/01/pytest-cov-collects-no-data-on-travis/

For newbies like me, just for clarity, please note this solution requires adding file tests/(underscore)(underscore)init(underscore)(underscore).py aka __init__.py like any other package

Is it preferable to extend the file tox.ini section [testenv] with usedevelop = true ? That works as well as adding an init file, but what are the tradeoffs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests