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

Side by Side Diff: Lib/test/test_collections.py

Issue 22189: collections.UserString missing some str methods
Patch Set: Created 4 years, 8 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Lib/collections/__init__.py ('k') | Misc/NEWS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Unit tests for collections.py.""" 1 """Unit tests for collections.py."""
2 2
3 import unittest, doctest, operator 3 import unittest, doctest, operator
4 from test.support import TESTFN, forget, unlink 4 from test.support import TESTFN, forget, unlink
5 import inspect 5 import inspect
6 from test import support 6 from test import support
7 from collections import namedtuple, Counter, OrderedDict, _count_elements 7 from collections import namedtuple, Counter, OrderedDict, _count_elements
8 from test import mapping_tests 8 from test import mapping_tests
9 import pickle, copy 9 import pickle, copy
10 from random import randrange, shuffle 10 from random import randrange, shuffle
11 import keyword 11 import keyword
12 import re 12 import re
13 import sys 13 import sys
14 from collections import UserDict
15 from collections import ChainMap 14 from collections import ChainMap
16 from collections import deque 15 from collections import deque
16 from collections import UserString, UserList, UserDict
17 from collections.abc import Hashable, Iterable, Iterator 17 from collections.abc import Hashable, Iterable, Iterator
18 from collections.abc import Sized, Container, Callable 18 from collections.abc import Sized, Container, Callable
19 from collections.abc import Set, MutableSet 19 from collections.abc import Set, MutableSet
20 from collections.abc import Mapping, MutableMapping, KeysView, ItemsView 20 from collections.abc import Mapping, MutableMapping, KeysView, ItemsView
21 from collections.abc import Sequence, MutableSequence 21 from collections.abc import Sequence, MutableSequence
22 from collections.abc import ByteString 22 from collections.abc import ByteString
23
24
25 class TestUserObjects(unittest.TestCase):
26 def _superset_test(self, a, b):
27 self.assertGreaterEqual(
28 set(dir(a)),
29 set(dir(b)),
30 '{a} should have all the methods of {b}'.format(
31 a=a.__name__,
32 b=b.__name__,
33 ),
34 )
35 def test_str_protocol(self):
36 self._superset_test(UserString, str)
37
38 def test_list_protocol(self):
39 self._superset_test(UserList, list)
40
41 def test_dict_protocol(self):
42 self._superset_test(UserDict, dict)
23 43
24 44
25 ################################################################################ 45 ################################################################################
26 ### ChainMap (helper class for configparser and the string module) 46 ### ChainMap (helper class for configparser and the string module)
27 ################################################################################ 47 ################################################################################
28 48
29 class TestChainMap(unittest.TestCase): 49 class TestChainMap(unittest.TestCase):
30 50
31 def test_basics(self): 51 def test_basics(self):
32 c = ChainMap() 52 c = ChainMap()
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 ################################################################################ 1655 ################################################################################
1636 ### Run tests 1656 ### Run tests
1637 ################################################################################ 1657 ################################################################################
1638 1658
1639 import doctest, collections 1659 import doctest, collections
1640 1660
1641 def test_main(verbose=None): 1661 def test_main(verbose=None):
1642 NamedTupleDocs = doctest.DocTestSuite(module=collections) 1662 NamedTupleDocs = doctest.DocTestSuite(module=collections)
1643 test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, 1663 test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,
1644 TestCollectionABCs, TestCounter, TestChainMap, 1664 TestCollectionABCs, TestCounter, TestChainMap,
1645 TestOrderedDict, GeneralMappingTests, SubclassMappingTests] 1665 TestOrderedDict, GeneralMappingTests, SubclassMappingTests,
1666 TestUserObjects]
1646 support.run_unittest(*test_classes) 1667 support.run_unittest(*test_classes)
1647 support.run_doctest(collections, verbose) 1668 support.run_doctest(collections, verbose)
1648 1669
1649 1670
1650 if __name__ == "__main__": 1671 if __name__ == "__main__":
1651 test_main(verbose=True) 1672 test_main(verbose=True)
OLDNEW
« 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+