Running a two-level package doesn't work

Issue #242 resolved
Ned Batchelder repo owner created an issue
cdunklau@krusty:~/Development/coverageissue$ venv/bin/python -m salesforce_client.test_query
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
cdunklau@krusty:~/Development/coverageissue$ venv/bin/coverage run -m salesforce_client.test_query
No module named salesforce_client



cdunklau@krusty:~/Development/coverageissue$ find salesforce_client 
salesforce_client
salesforce_client/query.pyc
salesforce_client/test_query.py
salesforce_client/query.py
salesforce_client/__init__.py
salesforce_client/__init__.pyc



cdunklau@krusty:~/Development/coverageissue$ cat salesforce_client/query.py
def hello(name):
    return "hello, %s" % name
cdunklau@krusty:~/Development/coverageissue$ cat salesforce_client/test_query.py 
import unittest

from salesforce_client.query import hello

class HelloTest(unittest.TestCase):
    def test_hello(self):
        self.assertEqual(
            hello('bob'),
            'hello, bob'
        )


if __name__ == '__main__':
    unittest.main()
cdunklau@krusty:~/Development/coverageissue$ cat salesforce_client/__init__.py
cdunklau@krusty:~/Development/coverageissue$ source venv/bin/activate
(venv)cdunklau@krusty:~/Development/coverageissue$ python -m salesforce_client.test_query
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
(venv)cdunklau@krusty:~/Development/coverageissue$ coverage run -m salesforce_client.test_query
No module named salesforce_client
(venv)cdunklau@krusty:~/Development/coverageissue$ coverage debug sys
-- sys ----------------------------------------
        version: 3.6
       coverage: /home/cdunklau/Development/coverageissue/venv/local/lib/python2.7/site-packages/coverage/__init__.pyc
      cover_dir: /home/cdunklau/Development/coverageissue/venv/lib/python2.7/site-packages/coverage
     pylib_dirs: /usr/lib/python2.7
         tracer: CTracer
   config_files: .coveragerc
   configs_read: -none-
      data_path: /home/cdunklau/Development/coverageissue/.coverage
         python: 2.7.3rc2 (default, Apr 22 2012, 22:30:17) [GCC 4.6.3]
       platform: Linux-3.2.0-4-amd64-x86_64-with-debian-wheezy-sid
 implementation: CPython
     executable: /home/cdunklau/Development/coverageissue/venv/bin/python
            cwd: /home/cdunklau/Development/coverageissue
           path: /home/cdunklau/Development/coverageissue/venv/bin
                 /home/cdunklau/Development/coverageissue/venv/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg
                 /home/cdunklau/Development/coverageissue/venv/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg
                 /home/cdunklau/Development/coverageissue/venv/lib/python2.7
                 /home/cdunklau/Development/coverageissue/venv/lib/python2.7/plat-linux2
                 /home/cdunklau/Development/coverageissue/venv/lib/python2.7/lib-tk
                 /home/cdunklau/Development/coverageissue/venv/lib/python2.7/lib-old
                 /home/cdunklau/Development/coverageissue/venv/lib/python2.7/lib-dynload
                 /usr/lib/python2.7
                 /usr/lib/python2.7/plat-linux2
                 /usr/lib/python2.7/lib-tk
                 /home/cdunklau/Development/coverageissue/venv/local/lib/python2.7/site-packages
    environment: PYTHONSTARTUP = /home/cdunklau/.pythonrc

Comments (2)

  1. Ned Batchelder reporter

    When running "python", sys.path has an empty first element (current dir), but "coverage debug sys" shows no such entry.

  2. Log in to comment