run -m fails to run on zipped python distributions

Issue #350 new
theiviaxx
created an issue

The use case is Maya, but would apply to any other distribution of python in its zipped form. Maya has mayapy.exe and works great, however all of pythons standard lib is zipped. It looks like imp is unable to find the module if it lives inside a zip file. so running

coverage.exe run -m unittest discover

will yield

No module named unittest

Comments (4)

  1. Loic Dachary

    It works with coverage 4.2

    (v) loic@fold:/tmp/g$ pip install coverage
    Collecting coverage
    Installing collected packages: coverage
    Successfully installed coverage-4.2
    (v) loic@fold:/tmp/g$ PYTHONPATH=zp.zip coverage run f.py
    Hello
    (v) loic@fold:/tmp/g$ PYTHONPATH=zp.zip coverage report -m
    Name                    Stmts   Miss  Cover   Missing
    -----------------------------------------------------
    f.py                        2      0   100%
    zp.zip/zp/__init__.py       0      0   100%
    zp.zip/zp/sample.py         2      0   100%
    -----------------------------------------------------
    TOTAL                       4      0   100%
    (v) loic@fold:/tmp/g$ unzip -t zp.zip
    Archive:  zp.zip
        testing: zp/                      OK
        testing: zp/__init__.py           OK
        testing: zp/sample.py             OK
    No errors detected in compressed data of zp.zip.
    (v) loic@fold:/tmp/g$ cat f.py
    from zp import sample
    sample.f()
    
  2. theiviaxx reporter

    just tried on 4.3.1 and i get the same error. i'll try to dig around a little more to see if this is in fact something with coverage or just a mayapy thing

  3. Log in to comment