Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64219 > unrolled thread

Re: doctests compatibility for python 2 & python 3

Started byAlbert-Jan Roskam <fomcl@yahoo.com>
First post2014-01-18 00:39 -0800
Last post2014-01-18 00:39 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: doctests compatibility for python 2 & python 3 Albert-Jan Roskam <fomcl@yahoo.com> - 2014-01-18 00:39 -0800

#64219 — Re: doctests compatibility for python 2 & python 3

FromAlbert-Jan Roskam <fomcl@yahoo.com>
Date2014-01-18 00:39 -0800
SubjectRe: doctests compatibility for python 2 & python 3
Message-ID<mailman.5672.1390034547.18130.python-list@python.org>
--------------------------------------------
On Fri, 1/17/14, Terry Reedy <tjreedy@udel.edu> wrote:

 Subject: Re: doctests compatibility for python 2 & python 3
 To: python-list@python.org
 Date: Friday, January 17, 2014, 10:10 PM
 
 On 1/17/2014 7:14 AM, Robin Becker
 wrote:
 
 > I tried this approach with a few more complicated
 outcomes and they fail
 > in python2 or 3 depending on how I try to render the
 result in the doctest.
 
 I never got how you are using doctests. There were certainly
 not meant for heavy-duty unit testing, but for testing
 combined with explanation. Section 26.2.3.7. (in 3.3)
 Warnings warns that they are fragile to even single char
 changes and suggests == as a workaround, as 'True' and
 'False' will not change. So I would not reject that option.
 

=====> I used doctests in .txt files and I converted ALL of them when I wanted to make my code work for both Python 2 and 3. I tried to fix something like a dozen of them so they'd work in Python 2.7 and 3,3. but I found it just too cumbersome and time consuming. The idea of doctest is super elegant, but it is really only meant for testable documentation (maybe with sphinx). If you'd put all the (often boring, e.g. edge cases) test cases in docstrings, the .py file will look very cluttered. One thing that I missed in unittest was Ellipsis, but: https://pypi.python.org/pypi/gocept.testing/1.6.0 offers assertEllipsis and other useful stuff.

Albert-Jan

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web