[pypy-svn] r4809 - pypy/trunk/src/pypy/objspace/std/test

alex at codespeak.net alex at codespeak.net
Tue Jun 1 16:21:44 CEST 2004


Author: alex
Date: Tue Jun  1 16:21:43 2004
New Revision: 4809

Added:
   pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py
Log:
a start for more, better tests of string formatting



Added: pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py	Tue Jun  1 16:21:43 2004
@@ -0,0 +1,25 @@
+import autopath
+from pypy.tool import testit
+
+
+class TestStringObject(testit.AppTestCase):
+
+    def setUp(self):
+        self.space = testit.objspace('std')
+
+    def test_format_item(self):
+        self.assertEquals('a23b', 'a%sb' % 23)
+        self.assertEquals('23b', '%sb' % 23)
+        self.assertEquals('a23', 'a%s' % 23)
+        self.assertEquals('23', '%s' % 23)
+        self.assertEquals('a%b', 'a%%b' % ())
+        self.assertEquals('%b', '%%b' % ())
+        self.assertEquals('a%', 'a%%' % ())
+        self.assertEquals('%', '%%' % ())
+
+    def test_format_wrongchar(self):
+        self.assertRaises(ValueError, 'a%Zb'.__mod__, ((23,),))
+
+
+if __name__ == '__main__':
+    testit.main()



More information about the Pypy-commit mailing list