Syed Mohammed Mehdi
Syed Mohammed Mehdi

Reputation: 313

Pytest coverage.py errror

I unit testing python code and running command pytest --cov, test is running fine but coverage is not getting displayed and error is

INTERNALERROR>raise CoverageException("Couldn't use data file {!r}:{}".format(self.filename, msg))
INTERNALERROR> coverage.misc.CoverageException: Couldn't use data file'C:\\Users\\Desktop\\Pytest\\.coverage': Safety level may not be changed inside a transaction

Need help with this problem?

Upvotes: 2

Views: 4382

Answers (3)

BulatN
BulatN

Reputation: 3

Use coverage==6.3.1

This works for me

Link to certain version https://pypi.org/project/coverage/6.3.1/

Upvotes: 0

Julien Palard
Julien Palard

Reputation: 11546

Could be related to https://github.com/nedbat/coveragepy/issues/883#issuecomment-650562896 if you're using multiple pytests in parallel, in which case specifying a distinct coverage file for each run fixes it, like:

export COVERAGE_FILE=.coverage.SOMETHING_SPECIFIC_FOR_EACH_RUN

Upvotes: 0

Ned Batchelder
Ned Batchelder

Reputation: 375574

This has been mentioned a few times in the coverage.py issues, and the eventual discovery was that it's a bug in Python 3.6.0, but if you use 3.6.1 or later, you will be fine.

If that doesn't cover your case, feel free to open an issue with details of how to reproduce.

Upvotes: 1

Related Questions