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

Unified Diff: Lib/test/test_collections.py

Issue 22189: collections.UserString missing some str methods
Patch Set: Created 4 years, 8 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/collections/__init__.py ('k') | Misc/NEWS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_collections.py Tue Apr 14 00:15:42 2015 -0700
+++ b/Lib/test/test_collections.py Wed Apr 15 17:26:43 2015 -0400
@@ -11,9 +11,9 @@
import keyword
import re
import sys
-from collections import UserDict
from collections import ChainMap
from collections import deque
+from collections import UserString, UserList, UserDict
from collections.abc import Hashable, Iterable, Iterator
from collections.abc import Sized, Container, Callable
from collections.abc import Set, MutableSet
@@ -22,6 +22,26 @@
from collections.abc import ByteString
+class TestUserObjects(unittest.TestCase):
+ def _superset_test(self, a, b):
+ self.assertGreaterEqual(
+ set(dir(a)),
+ set(dir(b)),
+ '{a} should have all the methods of {b}'.format(
+ a=a.__name__,
+ b=b.__name__,
+ ),
+ )
+ def test_str_protocol(self):
+ self._superset_test(UserString, str)
+
+ def test_list_protocol(self):
+ self._superset_test(UserList, list)
+
+ def test_dict_protocol(self):
+ self._superset_test(UserDict, dict)
+
+
################################################################################
### ChainMap (helper class for configparser and the string module)
################################################################################
@@ -1642,7 +1662,8 @@
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,
TestCollectionABCs, TestCounter, TestChainMap,
- TestOrderedDict, GeneralMappingTests, SubclassMappingTests]
+ TestOrderedDict, GeneralMappingTests, SubclassMappingTests,
+ TestUserObjects]
support.run_unittest(*test_classes)
support.run_doctest(collections, verbose)
« no previous file with comments | « Lib/collections/__init__.py ('k') | Misc/NEWS » ('j') | no next file with comments »

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