Lorin Hochstein
Lorin Hochstein

Reputation: 59242

Is it possible to run a single doctest in Django using "manage.py test"

In my Django app, I have a mix of doctests (defined in models.py and views.py) and unit tests (defined in tests.py. I can invoke an individual unit test by doing:

manage.py test app.TestCase

However, this doesn't seem to work for the doctests. Is there some way to run a single doctest (defined in models.py or views.py)?

Upvotes: 3

Views: 611

Answers (3)

John Mee
John Mee

Reputation: 52313

Try it this way:

python -m doctest views.py

Upvotes: 0

aka
aka

Reputation: 46

I posted a small script that lets you run doctests in a specific file or module in your project. Running doctests from a specific file or module: LINK.

It makes sure that the correct testing environment is loaded (emulating what manage.py test does). Hope this helps.

Upvotes: 1

cethegeek
cethegeek

Reputation: 6394

I think the way python doctests work is to simply run all doctests in a module in the same interpreter instance.

I doubt that manage.py can alter that basic behavior of python doctests.

Upvotes: 3

Related Questions