dimanche 17 mai 2015

Making local copy of Python package accessible

My directory structure looks like this:

base/
    mypackage/
        __init__.py
        (package files)
    mytests/
        (test files)

To run the tests, normally I just run nosetests from the base directory. It correctly uses the local copy of my package, rather than the one in my Python installation.

I'm adding a new test into the mytests folder that takes a few minutes to run, so I don't want to run it every time I call nosetests. I was think that I'd just run it as a script, but it can't access the local copy of my package from the tests folder. I found this workaround for importing a module by path, but I need it to work on both 2.7 and 3.4, and I have relative imports inside the package anyway.

Is there a way to make this work? Either by directly importing the local copy, or by finding a way to run the slow test separately from the regular tests.

Aucun commentaire:

Enregistrer un commentaire