CodeUnit fails with eggs as the files aren't actually available for reading.
Issue #26 was marked as a duplicate of this issue.
Thanks! This is fixed in 92b5372042d2
Alas, it is not fixed everywhere consistently.
results.py and codeunit.py contain duplicated code.
The bug still exists in results.py:
if source is not None:
Similar bugs in parser.py (lines 27, 337)
should be fixed the same way.
This is due to the fact that the file __init__.py could be empty (its length is zero).
The fix is trivial: https://github.com/Vanuan/coveragepy/commit/f453ced8d611bc098f1da1c97c268ccbee20e9ff
Vanuan: can you provide some test scenarios?
I'm afraid I need some help here.
The test case should look like that:
where import_egg1.py contains import egg1 and egg1 is an egg module (and contains an empty __init__.py).
My best effort is here: https://github.com/Vanuan/coveragepy/commit/7cba3928c7fd20fd677fadc4809b36ae40454670
I tried to duplicate this using the egg1 egg in the tests directory, with coverage 4.0. There were no problems. Maybe I don't know how to reproduce it. If you can give me manual steps to make it fail, I'll re-open the issue.