jeudi 25 février 2016

Coverage : ImportError: cannot import name config

When I try to run this code I am getting: ImportError: cannot import name config in line 32 of this file:

lib/python2.7/site-packages/tests/functional_tests/fixtures/__init__.py

Any idea about the reason of this error?

import os
COV = None
if os.environ.get('FLASK_COVERAGE'):
    import coverage
    COV = coverage.coverage(branch=True, include='app/*')
    COV.start()

from flask.ext.script import Manager, Shell
from app import create_app, db
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)

@manager.command
def test(coverage=False):
    """Run the unit tests."""
    if coverage and not os.environ.get('FLASK_COVERAGE'):
        import sys
        os.environ['FLASK_COVERAGE'] = '1'
        os.execvp(sys.executable, [sys.executable] + sys.argv)
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)
    if COV:
        COV.stop()
        COV.save()
        print('Coverage Summary:')
        COV.report()
        basedir = os.path.abspath(os.path.dirname(__file__))
        covdir = os.path.join(basedir, 'tmp/coverage')
        COV.html_report(directory=covdir)
        print('HTML version: file://%s/index.html' % covdir)
        COV.erase()

if __name__ == '__main__':
    manager.run()


error log:

python coverage.py test

ERROR: tests.functional_tests.test_providers (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.functional_tests.test_providers
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/loader.py", line 252, in _find_tests
    module = self._get_module_from_name(name)
  File "/usr/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name
    __import__(name)
  File "/home/vagrant/myproject/venv/local/lib/python2.7/site-packages/tests/functional_tests/__init__.py", line 1, in <module>
    from . import fixtures
  File "/home/vagrant/myproject/venv/local/lib/python2.7/site-packages/tests/functional_tests/fixtures/__init__.py", line 32, in <module>
    from tests.functional_tests import config
ImportError: cannot import name config


----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

Aucun commentaire:

Enregistrer un commentaire