Django

Code

Ticket #6364 (new)

Opened 4 months ago

Last modified 3 months ago

Allow test runner to execute individual doctests

Reported by: david Assigned to: david
Component: Tools Version: SVN
Keywords: testing Cc: russellm
Triage Stage: Accepted Has patch: 1
Needs documentation: 1 Needs tests: 0
Patch needs improvement: 1

Description (Last modified by russellm)

For the moment, you can specify a test case or even a single test method in this test case but you can't use more than one doctest file easily and run tests file by file for instance.

The attached patch allow you to run doctests from your tests/ directory one by one:

python manage.py test app.doctest_filename_without_extension

Or all at once:

python manage.py test app

You just need doctests files with ".txt" extension. Comments are welcome.

Update: doctests can already be split across files using __tests__. However, the ability to execute tests on a fine grained level would be useful.

Attachments

patch_django_6364.diff (3.2 kB) - added by david on 01/11/08 14:06:31.

Change History

01/11/08 14:06:31 changed by david

  • attachment patch_django_6364.diff added.

01/11/08 14:07:07 changed by david

  • owner changed from nobody to david.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

01/12/08 04:41:54 changed by Simon Greenhill <dev@simon.net.nz>

  • needs_docs set to 1.
  • has_patch set to 1.
  • stage changed from Unreviewed to Ready for checkin.

Sounds like a rather good idea. I'll move to RFC and see what core says

01/12/08 05:09:50 changed by david

Thanks Simon, I know there are a lot of improvements to do (better error handling, documentation, etc) but I'd like to know if core is interested in this approach before spending too much time on this.

02/02/08 19:15:49 changed by mtredinnick

  • cc set to russellm.
  • stage changed from Ready for checkin to Design decision needed.

Let's not do this. It introduces "yet another way" to specify tests. Multiple doctests can already be specified via the __tests__ variable, so what we need is a way to identify them. Possibly <app_name>.<test_key> where test_key is the key name in the __tests__ dictionary might be most straightforward here.

Russell probably needs to have some input, too, since I have a recollection he's thought about this in the past.

[Triagers: please use "design decision needed" for these types of tickets, not "ready for checkin", which is for non-controversial, fully complete stuff.]

02/02/08 21:12:06 changed by russellm

  • needs_better_patch set to 1.
  • summary changed from Allow fine grained tests for doctests (allow splitting into many files) to Allow test runner to execute individual doctests.
  • description changed.
  • stage changed from Design decision needed to Accepted.

I'm all in favour of the idea of greater granularity for running doctests. However, as Malcolm rightly points out, doctests already provide a multi-file option through the __tests__ dictionary. The Django test runner should supplement, not replace this approach.

Invoking parts of a __tests__ dictionary would certainly be a valuable contribution, but it doesn't completely solve the problem. Doctests can be defined inline on a method or class (the classic sense of a doctest); it would be nice to be able to invoke these individual tests, too.

I'll mark this as accepted, but for the concept, not the provided implementation. I've updated the ticket to better reflect the accepted idea.

02/04/08 06:20:11 changed by david

Ok, I'll try to do something with __tests__, thanks for your suggestions. Inline doctests looks a bit trickier at first sight.


Add/Change #6364 (Allow test runner to execute individual doctests)




Change Properties
Action