-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
5.0: Coverage report generation failure #716
Comments
Can you give me instructions for reproducing this problem? |
The relevant code is in this repo, |
Did not mention, but the pytest with coverage runs successfully for the 5.0a2 version. |
We are observing this error in one repo, and a similar one (shown below) in another repo. Both were working with 5.02a. INTERNALERROR> Traceback (most recent call last): |
@krisrogers if you could provide reproduction instructions, it would be very helpful, thanks :) |
I'm hitting this in my test suites, and I think I've narrowed it down to tests run with # mymodule.py
from subprocess import Popen
import sys
def foo():
pass
def bar():
pass
def test_foo():
foo()
def test_subprocess():
"""this test triggers coveragepy#716"""
p = Popen([sys.executable, __file__])
p.communicate()
if __name__ == "__main__":
bar()
I don't know enough to say if this is an issue with coverage.py or something that should be updated in pytest-cov, but it seems like there's a race to create the lines corresponding to files touched in both processes. I don't know how touching the coverage database is coordinated between processes, but there is definitely a race where rows created by other processes between the initialization of |
#718 fixes this issue for me by using |
@nedbat Sorry, can't provide reproduction details; I'm observing this in a commercial code base; Here is the tox file though, if it helps |
For the "UNIQUE constraint failed: file.path" problem: you need to use |
@tyacbovi I can't reproduce the problem you show. Since reporting this problem, you've pinned coverage to 4.5.1. I tried using commit 7c5117b5 of your repo, but it also installs 4.5.1. I manually pinned coverage to 5.0a3, and still did not see the problem. Do you only see the issue on CircleCI? I'm running on a Mac. Can you give me specific instructions to get the right version of the code, and how to run the tests? I used "tox -e py27_script_plugin" based on the output you showed. |
@tyacbovi Oops, never mind. I did it again and got the error you showed. Not sure what happened there.... I'm looking into it. |
The collector calls set_context() before any code is run. If we touch the database there, it will get created *very* early. This causes problems with pytest-cov, which will delete those early-created files when erasing data. By deferring the database access until add_lines is called, the data file stays off the disk until the collection is done (or until the context switches), which avoids the problem.
The "no such table: meta" problem is fixed in ae9f040. |
@nedbat I wanted to ask when are you planning to release a new version with this bug fix? |
This was released as part of 5.0a4, today. |
edit: The original message was wrong. I fixed it to be correct. With the following I get the error:
A quick-fix for me was to change the requirement to:
|
@MartinThoma Can you give us a way to reproduce the error you are seeing? |
@nedbat Sorry, the original message I wrote was wrong. The message I got is here https://travis-ci.org/MartinThoma/clana/jobs/636595136 :
Forcing |
@nedbat I've added the details. |
@nedbat This has come up again with the latest coverage (5.0.3):
We are using nosetests in parallel mode with coverage. The relevant setup.cfg: and tox.ini: Downgrading to <5.0.0 seems to fix the problem. |
I missed it before, but @nedbat already mentioned a fix: Add the following lines to your
No need to use an old coverage version edit: I see Again, I would recommend to set |
coverage-5.0 expects to set "parallel = True" on config file. refs: nedbat/coveragepy#716 (comment)
I think this issue should be opened again. |
After the current release of 5.0a3, the coverage generation is failing.
I am using the following packages for running my tests:
Python 2.7.15, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
plugins: xdist-1.23.2, forked-0.2, cov-2.6.0
The failure stack trace:
.......................................................INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 178, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 215, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/plugin.py", line 228, in pytest_runtestloop
INTERNALERROR> self.cov_controller.finish()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/engine.py", line 297, in finish
INTERNALERROR> self.cov.save()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 527, in save
INTERNALERROR> data = self.get_data()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 581, in get_data
INTERNALERROR> if self._collector and self._collector.flush_data():
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/collector.py", line 425, in flush_data
INTERNALERROR> self.covdata.add_lines(abs_file_dict(self.data))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 231, in add_lines
INTERNALERROR> self._choose_lines_or_arcs(lines=True)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 277, in _choose_lines_or_arcs
INTERNALERROR> con.execute("update meta set has_lines = ?, has_arcs = ?", (lines, arcs))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 534, in execute
INTERNALERROR> raise CoverageException("Couldn't use data file {!r}: {}".format(self.filename, exc))
INTERNALERROR> CoverageException: Couldn't use data file '/home/circleci/project/.coverage.905ab52c4304.2293.575964': no such table: meta
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 178, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 215, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/plugin.py", line 228, in pytest_runtestloop
INTERNALERROR> self.cov_controller.finish()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/engine.py", line 297, in finish
INTERNALERROR> self.cov.save()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 527, in save
INTERNALERROR> data = self.get_data()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 581, in get_data
INTERNALERROR> if self._collector and self._collector.flush_data():
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/collector.py", line 425, in flush_data
INTERNALERROR> self.covdata.add_lines(abs_file_dict(self.data))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 231, in add_lines
INTERNALERROR> self._choose_lines_or_arcs(lines=True)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 277, in _choose_lines_or_arcs
INTERNALERROR> con.execute("update meta set has_lines = ?, has_arcs = ?", (lines, arcs))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 534, in execute
INTERNALERROR> raise CoverageException("Couldn't use data file {!r}: {}".format(self.filename, exc))
INTERNALERROR> CoverageException: Couldn't use data file '/home/circleci/project/.coverage.905ab52c4304.2291.551230': no such table: meta
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 178, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 215, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/plugin.py", line 228, in pytest_runtestloop
INTERNALERROR> self.cov_controller.finish()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/engine.py", line 297, in finish
INTERNALERROR> self.cov.save()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 527, in save
INTERNALERROR> data = self.get_data()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 581, in get_data
INTERNALERROR> if self._collector and self._collector.flush_data():
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/collector.py", line 425, in flush_data
INTERNALERROR> self.covdata.add_lines(abs_file_dict(self.data))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 231, in add_lines
INTERNALERROR> self._choose_lines_or_arcs(lines=True)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 277, in _choose_lines_or_arcs
INTERNALERROR> con.execute("update meta set has_lines = ?, has_arcs = ?", (lines, arcs))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 534, in execute
INTERNALERROR> raise CoverageException("Couldn't use data file {!r}: {}".format(self.filename, exc))
INTERNALERROR> CoverageException: Couldn't use data file '/home/circleci/project/.coverage.905ab52c4304.2288.788971': no such table: meta
... [100%]INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 178, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/_pytest/main.py", line 215, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/plugin.py", line 228, in pytest_runtestloop
INTERNALERROR> self.cov_controller.finish()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/pytest_cov/engine.py", line 249, in finish
INTERNALERROR> self.cov.stop()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 527, in save
INTERNALERROR> data = self.get_data()
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/control.py", line 581, in get_data
INTERNALERROR> if self._collector and self._collector.flush_data():
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/collector.py", line 425, in flush_data
INTERNALERROR> self.covdata.add_lines(abs_file_dict(self.data))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 231, in add_lines
INTERNALERROR> self._choose_lines_or_arcs(lines=True)
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 277, in _choose_lines_or_arcs
INTERNALERROR> con.execute("update meta set has_lines = ?, has_arcs = ?", (lines, arcs))
INTERNALERROR> File "/home/circleci/project/.tox/py27_script_plugin/lib/python2.7/site-packages/coverage/sqldata.py", line 534, in execute
INTERNALERROR> raise CoverageException("Couldn't use data file {!r}: {}".format(self.filename, exc))
INTERNALERROR> CoverageException: Couldn't use data file '/home/circleci/project/.coverage': no such table: meta
The text was updated successfully, but these errors were encountered: