How do you manage doctrines (without a nose, that is)? If you cd'd in the package directory when you try to run them, you will have problems (if you are doing a full import, that is).
I was able to get a simple doctrist (with a fully qualified import), working with both nosetists and with a built-in bias. Here is my setup:
Project Structure:
. └── mypackage ├── __init__.py └── mod.py
Here is the contents of my mod.py file:
"""foo() providing module Example: >>> import mypackage.mod >>> mypackage.mod.foo() 'bar' """ def foo(): return "bar"
from '.' directory (root of the project), now I can run the tests:
$ python -m doctest -v mypackage/*.py 1 items had no tests: __init__ 0 tests in 1 items. 0 passed and 0 failed. Test passed. Trying: import mypackage.mod Expecting nothing ok Trying: mypackage.mod.foo() Expecting: 'bar' ok 1 items had no tests: mod.foo 1 items passed all tests: 2 tests in mod 2 tests in 2 items. 2 passed and 0 failed. Test passed.
And now the media:
$ nosetests --with-doctest . ---------------------------------------------------------------------- Ran 1 test in 0.008s OK
If I try to run doctest from the mypackage directory, I get an error message (which, I suspect is happening in your case).
Finally, I don't think this should matter, but I am running Python 2.7.2
Adam wagner
source share