[py-dev] running doctest-based tests

David Stanek dstanek at dstanek.com
Fri Jun 10 14:54:44 CEST 2005


On Fri, Jun 10, 2005 at 01:22:00PM +0200, holger krekel wrote:
> Hi Max, hi David, hi all, 
> 
> Oh sure, i am sorry.  Of course, i should have talked about 
> py.test.fail() all along! skip() doesn't make any sense here. 
> 
> I also think that your idea of just copying and maybe slightly modifying 
> the 2.4 doctest module into the py lib makes sense. The general idea is
> that py.test and the py lib should work sanely on python 2.2, 2.3, 2.4 
> and 2.5/cvs. 
> 
> If we integrate doctest support natively, then i now think that we 
> should aim for offering simple conftest.py configuration items like: 
> 
>     test_files = ['test_foo.py', 'test_bar.py']
>     extra_doctest_files = ['whatever.py', ...]
> 
> and test files should also be searched for doctests, btw. There would 
> then be no need to write custom Collectors/Items for changing the order 
> or the list of to-be-examined doctest modules.  The above example
> file lists would only be associated with the directory containing
> the conftest.py file and not any subdirectories.  On the implementation 
> side, the given files should always be imported via the path.pyimport() 
> method which imports modules with their fully qualified name. 
> (http://codespeak.net/py/current/doc/test.html#package-name) 
> 
> David, are you interested in taking a stab at this?  It's a bit
Sure.
> involved, i am afraid, also because it involves changing some reporting
> functionality.  If you or anyone else would like to do it, please make 
> sure to write proper tests for any new features even though it's sometimes 
> a bit involved to do that.  I sometimes spend half the time for writing 
> tests for new py lib features but it really pays off. 

Holger,
After we talked last night I was thinking about making the change to
both py.test.skip() and py.test.fail(). I agree with Max that this
is a hack and probably not the best way to do it. So I started to
work in a slightly different direction. I was thinking a more
general approach would be to factor out the view logic into it's own
class heirarchy.

Here is what I was thinking:
 * added an additional param to fail() and skip(), defaulted to None
 * factored out the py.test.TerminalSession's repr_* functions into
   py.test.view.(BaseOutcomeView & DefaultOutcomeView) classes

Then the conftest.py can select a custom view class and attach it to
the outcome.

-- 
David Stanek
www.roninds.net

GPG keyID #6272EDAF on http://pgp.mit.edu
Key fingerprint = 8BAA 7E11 8856 E148 6833  655A 92E2 3E00 6272 EDAF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20050610/bfc9ec0d/attachment.pgp>


More information about the Pytest-dev mailing list