[pypy-svn] r40035 - in pypy/dist/pypy/lib: . test2
hpk at codespeak.net
hpk at codespeak.net
Wed Mar 7 17:34:55 CET 2007
Author: hpk
Date: Wed Mar 7 17:34:54 2007
New Revision: 40035
Added:
pypy/dist/pypy/lib/test2/test_formatting.py (contents, props changed)
Modified:
pypy/dist/pypy/lib/_formatting.py
Log:
Issue296 resolved
added the beginnings of a direct test file for string interpolation,
first testing/fixing the regression introduced by the string interp
refactorings during the sprint. (Note: you need to remove _cache,
at least i had to do that to have the fix effectively)
Modified: pypy/dist/pypy/lib/_formatting.py
==============================================================================
--- pypy/dist/pypy/lib/_formatting.py (original)
+++ pypy/dist/pypy/lib/_formatting.py Wed Mar 7 17:34:54 2007
@@ -304,7 +304,6 @@
v = self.valuebox.str()
if len(v) != 1:
raise TypeError, "%c requires int or char"
-
elif self.valuebox.isunicode():
raise NeedUnicodeFormattingError
else:
@@ -507,6 +506,8 @@
def isint(self):
return isinstance(self._value, int)
+ def isstr(self):
+ return isinstance(self._value, str)
def isunicode(self):
return isinstance(self._value, unicode)
Added: pypy/dist/pypy/lib/test2/test_formatting.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/test2/test_formatting.py Wed Mar 7 17:34:54 2007
@@ -0,0 +1,15 @@
+
+import py
+
+from pypy.lib._formatting import format, NeedUnicodeFormattingError
+
+def test_charformatter():
+ res = format("%c", ("a",))
+ assert res == "a"
+ res = format("%c", (ord("b"),))
+ assert res == "b"
+ py.test.raises(TypeError,
+ "format('%c', ('qw',))")
+ #py.test.raises(NeedUnicodeFormattingError,
+ # "format(u'%c', (u'b',))")
+
More information about the Pypy-commit
mailing list