[pypy-svn] r5673 - in pypy/trunk/src/pypy/tool: . test
lac at codespeak.net
lac at codespeak.net
Mon Jul 26 10:59:09 CEST 2004
Author: lac
Date: Mon Jul 26 10:59:08 2004
New Revision: 5673
Modified:
pypy/trunk/src/pypy/tool/test/test_utestconvert.py
pypy/trunk/src/pypy/tool/test/test_utestconvert2.py
pypy/trunk/src/pypy/tool/utestconvert.py
Log:
In a different program I found a person in the habit of writing two
unittests per line, when they can fit:
self.assertEquals(dog, cat); self.assertEquals(mouse, rat)
(actually they are a firm believer that whitespace after argument
separating commas are deadly poison, but you get the idea.) The
program converts the first one, and takes the rest as a trailing
comment, which it passes unchanged. I have no plans to change this
behaviour at the moment, only document it, but will do so if you
think it is worth it.
Modified: pypy/trunk/src/pypy/tool/test/test_utestconvert.py
==============================================================================
--- pypy/trunk/src/pypy/tool/test/test_utestconvert.py (original)
+++ pypy/trunk/src/pypy/tool/test/test_utestconvert.py Mon Jul 26 10:59:08 2004
@@ -394,6 +394,18 @@
"is not in sys.modules.")
"""
)
+
+ # two unittests on the same line separated by a semi-colon is
+ # only half-converted. Just so you know.
+ assert rewrite_utest(
+ """
+ self.assertEquals(0, 0); self.assertEquals(1, 1) #not 2 per line!
+ """
+ ) == (
+ """
+ assert 0 == 0; self.assertEquals(1, 1) #not 2 per line!
+ """
+ )
if __name__ == '__main__':
Modified: pypy/trunk/src/pypy/tool/test/test_utestconvert2.py
==============================================================================
--- pypy/trunk/src/pypy/tool/test/test_utestconvert2.py (original)
+++ pypy/trunk/src/pypy/tool/test/test_utestconvert2.py Mon Jul 26 10:59:08 2004
@@ -369,19 +369,31 @@
self.assertEquals(rewrite_utest(
"""
- self.assertAlmostEquals(now do something reasonable ..()
+ self.assertAlmostEquals(now do something reasonable ..()
oops, I am inside a comment as a ''' string, and the fname was
mentioned in passing, leaving us with something that isn't an
expression ... will this blow up?
"""
),
"""
- self.assertAlmostEquals(now do something reasonable ..()
+ self.assertAlmostEquals(now do something reasonable ..()
oops, I am inside a comment as a ''' string, and the fname was
mentioned in passing, leaving us with something that isn't an
expression ... will this blow up?
"""
)
+
+ self.assertEquals(rewrite_utest(
+ """
+ happily inside a comment I write self.assertEquals(0, badger)
+ now will this one get rewritten?
+ """
+ ),
+ """
+ happily inside a comment I write self.assertEquals(0, badger)
+ now will this one get rewritten?
+ """
+ )
self.assertEquals(rewrite_utest(
"""
@@ -394,9 +406,19 @@
"is not in sys.modules.")
"""
)
+
+ # two unittests on the same line separated by a semi-colon is
+ # only half-converted. Just so you know.
+ self.assertEquals(rewrite_utest(
+ """
+ self.assertEquals(0, 0); self.assertEquals(1, 1) #not 2 per line!
+ """
+ ),
+ """
+ assert 0 == 0; self.assertEquals(1, 1) #not 2 per line!
+ """
+ )
if __name__ == '__main__':
unittest.main()
-
-
Modified: pypy/trunk/src/pypy/tool/utestconvert.py
==============================================================================
--- pypy/trunk/src/pypy/tool/utestconvert.py (original)
+++ pypy/trunk/src/pypy/tool/utestconvert.py Mon Jul 26 10:59:08 2004
@@ -132,7 +132,7 @@
trailer -- any extra junk after the closing paren, such as #commment
'''
- indent = re.search(r'^(\s*)', block).group()
+ indent = re.match(r'(\s*)', block).group()
pat = re.search('self.' + old + r'\(', block)
args, trailer = get_expr(block[pat.end():], ')')
More information about the Pypy-commit
mailing list