Frage

I have a Django project with setup.py which looks like this:

.
├── backend
├── backoffice
├── backoffice_set
├── manage.py
├── MANIFEST.in
├── media
├── README.rst
├── requirements.txt
├── setup.py
└── venv2.7

When I run: python setup.py test everything is O.K.. However, when I run :

/opt/bin/coverage run setup.py test

The tests fail with:

writing dependency_links to cfe_backoffice.egg-info/dependency_links.txt
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'backoffice/templates/backoffice/'
writing manifest file 'cfe_backoffice.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    setup(
  File "/opt/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/opt/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/opt/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 138, in run
    self.with_project_on_sys_path(self.run_tests)
  File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 118, in with_project_on_sys_path
    func()
  File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 164, in run_tests
    testLoader = cks
  File "/opt/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/opt/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/opt/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/opt/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/opt/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'runtests'

Has anyone seen this before? Can you suggest a solution?

War es hilfreich?

Lösung

Well, after a while I found the solution. Django was not installed globally, which is what I wanted.

I created my virtual environment with:

 virtualenv --enable-system-packages

So this lead to coverage.py not being installed inside my virtualenv. Hence the solution, which was to force pip to install it with -I, here is the full log of actions:

/opt/bin/virtualenv --system-site-packages venv2.7
. venv2.7/bin/activate
pip install -r requirements.txt 
pip install -I coverage
coverage run setup.py test
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top