Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64352
| From | Robin Becker <robin@reportlab.com> |
|---|---|
| Subject | Re: doctests compatibility for python 2 & python 3 |
| Date | 2014-01-20 10:07 +0000 |
| References | <52D91101.7000202@chamonix.reportlab.co.uk> <CAPTjJmqhr9V42ncZHKKGnE=N8KuUmV2t6M3eNYfZzkPNTYQF9A@mail.gmail.com> <CAPTjJmo6XqfZL5xYB-2pyhv+fsmB-faPrLK3y8-dcqRQFEyC9A@mail.gmail.com> <52D91EBB.2060606@chamonix.reportlab.co.uk> <lbc68l$atj$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5743.1390212469.18130.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: doctests compatibility for python 2 & python 3 Robin Becker <robin@reportlab.com> - 2014-01-20 10:07 +0000
csiph-web