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

## Side by Side Diff: Lib/test/test_functools.py

Issue 25958: Implicit ABCs have no means of "anti-registration"
Patch Set: Created 4 years, 3 months ago
 Left: Base Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None Patch Set 6: None Patch Set 7: None Right: Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None Patch Set 6: None Patch Set 7: None
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
OLDNEW
1 import abc 1 import abc
2 import collections 2 import collections
3 import copy 3 import copy
4 from itertools import permutations 4 from itertools import permutations
5 import pickle 5 import pickle
6 from random import choice 6 from random import choice
7 import sys 7 import sys
8 from test import support 8 from test import support
9 import unittest 9 import unittest
10 from weakref import proxy 10 from weakref import proxy
(...skipping 1417 matching lines...)
1428 # preceeds MutableMapping which means single dispatch will always 1428 # preceeds MutableMapping which means single dispatch will always
1429 # choose MutableSequence here. 1429 # choose MutableSequence here.
1430 class D(c.defaultdict): 1430 class D(c.defaultdict):
1431 pass 1431 pass
1432 c.MutableSequence.register(D) 1432 c.MutableSequence.register(D)
1433 bases = [c.MutableSequence, c.MutableMapping] 1433 bases = [c.MutableSequence, c.MutableMapping]
1434 for haystack in permutations(bases): 1434 for haystack in permutations(bases):
1435 m = mro(D, bases) 1435 m = mro(D, bases)
1436 self.assertEqual(m, [D, c.MutableSequence, c.Sequence, 1436 self.assertEqual(m, [D, c.MutableSequence, c.Sequence,
1437 c.defaultdict, dict, c.MutableMapping, 1437 c.defaultdict, dict, c.MutableMapping,
1438 c.Mapping, c.Sized, c.Iterable, c.Container, 1438 c.Mapping, c.Sized, c.Reversible,
1439 c.Iterable, c.Container,
1439 object]) 1440 object])
1440 1441
1441 # Container and Callable are registered on different base classes and 1442 # Container and Callable are registered on different base classes and
1442 # a generic function supporting both should always pick the Callable 1443 # a generic function supporting both should always pick the Callable
1443 # implementation if a C instance is passed. 1444 # implementation if a C instance is passed.
1444 class C(c.defaultdict): 1445 class C(c.defaultdict):
1445 def __call__(self): 1446 def __call__(self):
1446 pass 1447 pass
1447 bases = [c.Sized, c.Callable, c.Container, c.Mapping] 1448 bases = [c.Sized, c.Callable, c.Container, c.Mapping]
1448 for haystack in permutations(bases): 1449 for haystack in permutations(bases):
(...skipping 361 matching lines...)
1810 g.register(dict, lambda arg: "dict") 1811 g.register(dict, lambda arg: "dict")
1811 self.assertEqual(g(d), "dict") 1812 self.assertEqual(g(d), "dict")
1812 self.assertEqual(g(l), "list") 1813 self.assertEqual(g(l), "list")
1813 g._clear_cache() 1814 g._clear_cache()
1814 self.assertEqual(len(td), 0) 1815 self.assertEqual(len(td), 0)
1815 functools.WeakKeyDictionary = _orig_wkd 1816 functools.WeakKeyDictionary = _orig_wkd
1816 1817
1817 1818
1818 if __name__ == '__main__': 1819 if __name__ == '__main__':
1819 unittest.main() 1820 unittest.main()
OLDNEW

This is Rietveld 894c83f36cb7+