coveragepy: SQLite Crash on Coverage 5.0a2 inside Hypothesis

I was running some unit tests using hypothesis (link) which relies on coverage, and I ran into a crash. Specifically, I received the following error message: coverage.misc.CoverageException: Couldn't use data file '/Users/me/my_project/.coverage': UNIQUE constraint failed: file.path

I have experienced this issue both on macOS and Linux while running python 3.6, and the issue does not persist with COVERAGE_STORAGE=json.

I have included a gist below which contains files to reproduce the error. Specifically, the error occurs when the hypothesis assume statement in test.py fails more than half the time and when wrap is called.

To reproduce the error, run the build.sh script, which will initialize a virtualenv, install required modules, and run a short example which should throw the error.

Additionally, I am including a vagrantfile which will run build.shin a VM, thus providing a clean slate for testing.

https://gist.github.com/TylerADavis/393ee6382b4f645774100ae0c490c5ba

Please let me know if there is any other information I could provide that would be useful.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve bisected this to d2f77ab2ffc308e616af0207546ee1bef1cb8c75.

The problem appears to be that the file_map is only read when opening the DB, but another subprocess might have added the file later when the ID is needed.

https://github.com/nedbat/coveragepy/pull/723 fixes this for me.

My test case is https://github.com/Vimjas/covimerage/ (https://github.com/Vimjas/covimerage/commit/bb84cc9fbbc1750ce82c5add4d8f7d5a5429bef7), using tox -e py37-coveragepy5-coverage -- -x. (The initial failure is due to an autouse fixture, but also without this it fails, but later.)

To be clear: I am seeing the problem @anarcat mentioned, and which might be different from the original issue, sorry.