run -m cannot find module (or package) in current directory

Issue #207 resolved
Antony Lee
created an issue

The directory from which coverage was started should be added at the beginning of sys.path (or perhaps even replace the first entry of sys.path, which is the directory where coverage is installed), so that coverage run -m foo can find foo in that directory (just as python -m foo can find foo in that directory).

Perhaps this modification should be made temporary though (e.g. by fooling around in

Comments (6)

  1. Ned Batchelder repo owner

    Can you provide more details? I've tried but can't reproduce the problem you're reporting. Do you have a zipfile that demonstrates it? What OS and Python version are you using?

  2. Antony Lee reporter

    Create a folder package containing (empty) files and, and try coverage run -m package (from the folder containing package). I get the error message No module named 'package', sometimes with the extra error

    "Exception AttributeError: "'NoneType' object has no attribute 'isabs'" in <function _remove at ...> ignored"

    (this error may or may not appear in a seemingly random fashion). On the other hand python -m package works as expected.

    This is on Arch Linux with Python 2.7.3 or 3.3.0, and coverage 3.5.2.

  3. Log in to comment