[pypy-dev] utest conversion tool question

Laura Creighton lac at strakt.com
Thu Jul 1 07:31:30 CEST 2004


In a message of Wed, 30 Jun 2004 20:55:34 +0200, holger krekel writes:
>Hey Laura, 
>
>[Laura Creighton Wed, Jun 30, 2004 at 04:43:25PM +0200]
>> I am still dizzy and sick, but I am trying to get something done anyhow
>.  I have
>> this question.
>
>ups, didn't know you were ill, but you seem to have fun recovering :-) 
>
>> If you start with
>> 
>> self.assertEquals(f(x) +
>>                   g(x) == q(x), 'Message to print when the assertion fa
>ils')
>
>Oh,                     ^^^^ you mean a comma here, i guess?!


Yes.  silly me.

>> you would like things to come back as
>> 
>> assert f(x) +\
>>                  g(x) == q(x), 'Message to print when the assertion fai
>ls'
>
>actually i'd prefer 
>
>  assert f(x) + g(x) == q(x), 'Message to print when the assertion fails'
>
>Because i think the output logic should just format it so that it looks
>nice (e.g. less < 76 characters per line) and retain the correct
>semantics of the original statement.  I wouldn't worry about the 
>original input format, though.  If this proves too hard then maybe blame 
>Armin who suggested the 'comma'-try-parsing-withought-understanding-the
>expression-tricks :-)

It is not too hard, but at some point you have to face the 'my input is more
than 76 chars long' problem.  I thought it would be better to preserve the
spacing written by the original unittest user, breaking it wherever they did
if possible.  There is no problem in stripping out the newlines, and seeing if what 
you get is smaller than 78 chars, but what shall we do if the answer is 'no'?
Adding parenthesis will work.

see:
ython 2.3.4 (#2, May 29 2004, 03:31:27)
[GCC 3.3.3 (Debian 20040417)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import unittest
>>> class Testit(unittest.TestCase):
...     def test(self):
...             self.assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
...                     + 11, 0, '''A huge US Style disclaimer to print when
... we fail.  You can't sue me even if this program makes your computer
... explode, and gives your dogs fleas.''')
...
>>> unittest.main()
F
======================================================================
FAIL: test (__main__.Testit)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 6, in test
  File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual
    raise self.failureException, \
AssertionError: A huge US Style disclaimer to print when
we fail.  You can't sue me even if this program makes your computer
explode, and gives your dogs fleas.

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)

At any rate, if you think the output isn't pretty enough, there will be
plenty of time to criticise ...

Laura, brain still full of high pitched squeals.  (Tintinitus is very interesting,
but I've satisfied my curiosity about it for a while ... :-) )








More information about the Pypy-dev mailing list