Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64352 > unrolled thread
| Started by | Robin Becker <robin@reportlab.com> |
|---|---|
| First post | 2014-01-20 10:07 +0000 |
| Last post | 2014-01-20 10:07 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: doctests compatibility for python 2 & python 3 Robin Becker <robin@reportlab.com> - 2014-01-20 10:07 +0000
| From | Robin Becker <robin@reportlab.com> |
|---|---|
| Date | 2014-01-20 10:07 +0000 |
| Subject | Re: doctests compatibility for python 2 & python 3 |
| Message-ID | <mailman.5743.1390212469.18130.python-list@python.org> |
On 17/01/2014 21:10, Terry Reedy wrote:
> On 1/17/2014 7:14 AM, Robin Becker wrote:
>
..........
> 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 have used some 'robust' True/False equality tests and also tests which return
None or a string indicating the expected and observed outcomes eg
>
> def equalStrings(a,b,enc='utf8'):
> return a==b if type(a)==type(b) else asUnicode(a,enc)==asUnicode(b,enc)
>
> def eqCheck(r,x):
> if r!=x:
> print('Strings unequal\nexp: %s\ngot: %s' % (ascii(x),ascii(r)))
of course I needed to import ascii from the future and the asUnicode function
has to be different for python 3 and 2.
Some of our code used doctests which are discovered by a file search.
--
Robin Becker
Back to top | Article view | comp.lang.python
csiph-web