dimanche 21 juin 2015

Unable to test Python project due to import errors

I have the following directory structure in my current project:

Project/
    project/
        __init__.py
        classifier.py
        util.py
        lib/
            __init__.py
           scraper.py
        tests/
           test_classifier.py
           test_util.py

I'm trying to run tests in the tests/ directory from within the Project/ directory, but am currently unable to do so. The reason is that the first line of each of my testing Python files is the following:

from project import Event, EventClassifier

and so I'm unable to directory call the testing files with something like the following:

python project/tests/test_util.py

Does anyone have a solution for this? I would imagine this is a pretty common problem, in that the Python convention is to include your testing directory inside of your main package.

Aucun commentaire:

Enregistrer un commentaire