Opened 16 years ago

Closed 8 years ago

#1595 enhancement closed wontfix (wontfix)

.txt file doctest support for trial

Reported by: radix Owned by:
Priority: normal Milestone:
Component: trial Keywords:
Cc: Branch:


It'd be way cool if trial had support for .txt -style doctests.

TestCase-wise, it should be fairly easy: have 'run' call 'doctest.testfile("foo.txt")'.

However, what should the filesystem and command line UI be? I assume "trial foo.txt" is fairly reasonable. How about interpreting test_foo.txt as a doctest file if it's found in a searched test directory?

I might work on this at some point, but I'll leave it assigned to jml for now.

Change History (7)

comment:1 Changed 16 years ago by Jean-Paul Calderone

trial is still a buggy mess. I'd really like to see it work before pushing forward on major new feature development.

comment:2 Changed 16 years ago by spiv

exarkun: thanks for your love and support ;)

I'm not sure that automatically discovering test_*.txt files is the right thing to do. DocFileSuites have a fair few flags that you might want to turn on, and it can be useful to have their namespace prepopulated with common useful functions. The zope runner solves this by executing a test_suite module global if it finds one, and this can explicitly construct DocFileSuites with the desired flags and environment. I think I'd like trial to have a similar facility.

comment:3 Changed 16 years ago by Jonathan Lange

Component: coretrial

Trial may be buggy, but I wouldn't call it a mess. I like spiv's suggestion. Trial has its own component.

comment:4 Changed 15 years ago by jdahlin

Random, but slightly related IRC contemplations:

(somewhat edited)

<jdahlin> radix: hmm, I'd rather have trial foo.txt work
<radix> jdahlin: that's a lot harder :)
<glyph> I would really rather 'trial foo.txt' not work
<glyph> 'trial --please-enable-doctests --yes-seriously-randomly-search-text-files-with-regular-expressions --and-while-youre-at-it-parse-microsoft-word-too'
<exarkun> glyph: 'trial foo.txt' is pretty explicit.
<exarkun> And not the same as 'trial twisted' inspecting .txt files it finds beneath twisted/
<exarkun> Hmm oh wait nevermind
<jdahlin> they could be named .doctest if that would make someone happier
<exarkun> Namespace collision!
<glyph> exarkun: then it's kind of inconsistent; it can operate on a *single* ".txt" file, OR a *tree* of python files?
<glyph> .doctest would make me happier
<exarkun> How about 'trial [twisted.trial.loaders.doctest:foo.txt]'
<jdahlin> how would you test README.txt then?
<exarkun> glyph: doctests are inconsistent, what's the problem?
<glyph> as long as trial is digging random crap out of text files, it should go all the way!
<jdahlin> well, trial could be made smart
<glyph> jdahlin: "README.txt" is not where your tests go
<jdahlin> for instance, by looking at the first line of the .txt file
<glyph> Nothing stopping you from putting them in README.doctest 
<jdahlin> if it contains -*- Mode: -*-, test it, otherwise don't
<jdahlin> err, Mode: doctest of course
<_keturn> glyph: README.txt is not where your tests go, but there may be examples in README.txt that need to be tested.
<radix> jdahlin: it's worth pointing out that the zope test runner even works if you specify a path to a .txt file
<radix> jdahlin: it searches the already-constructed testsuite tree

comment:5 Changed 11 years ago by <automation>

Owner: Jonathan Lange deleted

comment:6 Changed 9 years ago by Jean-Paul Calderone

I seem to recall a number of discussions where the consensus was that trial should not support this feature.

I think the gist was something like: doctests are a bad tool, trial shouldn't encourage people to use bad tools.

Twisted itself doesn't use doctests anywhere, so this isn't an internally motivated feature, at least.

Also, a more recent development, disttrial does not support doctests at all.

Anyone want to comment on this?

comment:7 Changed 8 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: newclosed

Apparently not.

Trial does support test_suite so if anyone wants to load doctests they can always implement that function.

Note: See TracTickets for help on using tickets.