[pypy-svn] pypy default: Fix these tests.
alex_gaynor
commits-noreply at bitbucket.org
Wed Jan 19 05:21:10 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r40918:1d137f24d3cc
Date: 2011-01-18 22:20 -0600
http://bitbucket.org/pypy/pypy/changeset/1d137f24d3cc/
Log: Fix these tests.
diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -110,6 +110,12 @@
else:
msg = "format_spec must be a string"
raise OperationError(space.w_TypeError, space.wrap(msg))
+ if space.int_w(space.len(w_format_spec)) > 0:
+ space.warn(
+ ("object.__format__ with a non-empty format string is "
+ "deprecated"),
+ space.w_PendingDeprecationWarning
+ )
return space.format(w_as_str, w_format_spec)
def descr___subclasshook__(space, __args__):
@@ -184,7 +190,7 @@
return slotnames
''', filename=__file__)
-reduce_1 = app.interphook('reduce_1')
+reduce_1 = app.interphook('reduce_1')
reduce_2 = app.interphook('reduce_2')
# ____________________________________________________________
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -136,18 +136,22 @@
assert self.s("{0:d}").format(G("data")) == self.s("G(data)")
assert self.s("{0!s}").format(G("data")) == self.s("string is data")
- expected_warning = [
- ("object.__format__ with a non-empty format string is deprecated", PendingDeprecationWarning),
- ]
- # XXX: need to change the filter so that PendingDeprecationWarnings are
- # issued and not ignored
+ msg = "object.__format__ with a non-empty format string is deprecated",
with warnings.catch_warnings(record=True) as log:
+ # This is ok because warnings.catch_warnings resets the filters
+ warnings.simplefilter("always", PendingDeprecationWarning)
assert self.s("{0:^10}").format(E("data")) == self.s(" E(data) ")
- assert log == expected_warning * 1
+ assert log[0].message.args == msg
+ assert type(log[0].message) is PendingDeprecationWarning
+
assert self.s("{0:^10s}").format(E("data")) == self.s(" E(data) ")
- assert log == expected_warning * 2
+ assert log[1].message.args == msg
+ assert type(log[1].message) is PendingDeprecationWarning
+
assert self.s("{0:>15s}").format(G("data")) == self.s(" string is data")
- assert log == expected_warning * 3
+ assert log[2].message.args == msg
+ assert type(log[2].message) is PendingDeprecationWarning
+ assert len(log) == 3
class AppTestUnicodeFormat(BaseStringFormatTests):
More information about the Pypy-commit
mailing list