diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-22 23:56:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-22 23:56:32 (GMT) |
commit | 573b44c18f69307d7dbc95c950aab57ef7ea303e (patch) | |
tree | ac416703afd065a5ab49c6fad5f1e9386fa614e9 /Lib/test/test_collections.py | |
parent | ab89f9c27fe66b64b5907aad941d58bbc2ede14d (diff) | |
download | cpython-573b44c18f69307d7dbc95c950aab57ef7ea303e.zip cpython-573b44c18f69307d7dbc95c950aab57ef7ea303e.tar.gz cpython-573b44c18f69307d7dbc95c950aab57ef7ea303e.tar.bz2 |
Issue 22189: Add missing methods to UserString
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index d96eae7..a15651f 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -12,7 +12,7 @@ import keyword import re import sys import types -from collections import UserDict +from collections import UserDict, UserString, UserList from collections import ChainMap from collections import deque from collections.abc import Awaitable, Coroutine, AsyncIterator, AsyncIterable @@ -24,6 +24,26 @@ from collections.abc import Sequence, MutableSequence 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) ################################################################################ @@ -1848,7 +1868,8 @@ def test_main(verbose=None): 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) |