6

When I run coverage run -m pytest tests/ followed by coverage report in the terminal

I get the following error:

No source for code: '/private/var/.../_remote_module_non_scriptable.py'.

It seems like a similar issue has been resolved already, however I do not understand the solution.

Can a friendly soul help me understand what might be the cause of the problem?

2
  • There are several simple and concrete suggestions in that post. (1) Delete all the .pyc files, (2) Do nosetests --with-coverage --cover-erase to accomplish the same thing. (3) Do coverage xml -i. Have you done any of those? Commented Jul 31, 2023 at 21:37
  • 2
    Hi @TimRoberts ,coverage xml -i worked for me. Generally, the -i just skipped the files it failed on (in my case the _remote_module_non_scriptable.py), so the prettier output coverage report -i also worked. Thanks. Commented Aug 1, 2023 at 8:52

1 Answer 1

4

coverage xml -i doesn't work for me.

I found out that the <tmpdir>/_remote_module_non_scriptable.py is generated by pytorch.

Solution: add to pyproject.toml

[tool.coverage.run]
omit = [
    # omit pytorch-generated files in /tmp
    "/tmp/*",
]
Sign up to request clarification or add additional context in comments.

1 Comment

For me, the temp file was in the /private/var/folders/ temp directory, which I omitted in pyproject.toml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.