Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(70)

Unified Diff: Lib/test/test_unicode.py

Issue 25958: Implicit ABCs have no means of "anti-registration"
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_iter.py ('k') | Objects/enumobject.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_unicode.py Mon Aug 15 03:23:23 2016 -0400
+++ b/Lib/test/test_unicode.py Mon Aug 15 23:52:53 2016 +0200
@@ -986,6 +986,19 @@
def __format__(self, format_spec):
return int.__format__(self * 2, format_spec)
+ class M:
+ def __init__(self, x):
+ self.x = x
+ def __repr__(self):
+ return 'M(' + self.x + ')'
+ __str__ = None
+
+ class N:
+ def __init__(self, x):
+ self.x = x
+ def __repr__(self):
+ return 'N(' + self.x + ')'
+ __format__ = None
self.assertEqual(''.format(), '')
self.assertEqual('abc'.format(), 'abc')
@@ -1200,6 +1213,16 @@
self.assertEqual("0x{:0{:d}X}".format(0x0,16), "0x0000000000000000")
+ # Blocking fallback
+ m = M('data')
+ self.assertEqual("{!r}".format(m), 'M(data)')
+ self.assertRaises(TypeError, "{!s}".format, m)
+ self.assertRaises(TypeError, "{}".format, m)
+ n = N('data')
+ self.assertEqual("{!r}".format(n), 'N(data)')
+ self.assertEqual("{!s}".format(n), 'N(data)')
+ self.assertRaises(TypeError, "{}".format, n)
+
def test_format_map(self):
self.assertEqual(''.format_map({}), '')
self.assertEqual('a'.format_map({}), 'a')
« no previous file with comments | « Lib/test/test_iter.py ('k') | Objects/enumobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+