cpython: afaad8dc8edf (original) (raw)

--- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1,19 +1,24 @@ +import collections +import copy +import doctest +import keyword +import operator +import pickle +import cPickle +from random import choice, randrange +import re +import string +import sys +from test import test_support +import unittest -import unittest, doctest, operator -import inspect -from test import test_support from collections import namedtuple, Counter, OrderedDict -from test import mapping_tests -import pickle, cPickle, copy -from random import randrange, shuffle -import keyword -import re -import sys from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable from collections import Set, MutableSet from collections import Mapping, MutableMapping from collections import Sequence, MutableSequence +

Silence deprecation warning

sets = test_support.import_module('sets', deprecated=True) @@ -178,8 +183,7 @@ class TestNamedTuple(unittest.TestCase): self.assertEqual(Dot(1)._fields, ('d',)) n = 5000

@@ -556,7 +560,7 @@ class TestCollectionABCs(ABCTestCase): def test_issue_4920(self): # MutableSet.pop() method did not work

@@ -802,7 +806,7 @@ class TestCollectionABCs(ABCTestCase): self.assertTrue(issubclass(sample, Mapping)) self.validate_abstract_methods(Mapping, 'contains', 'iter', 'len', 'getitem')

@@ -1038,290 +1042,11 @@ class TestCounter(unittest.TestCase): self.assertRaises(TypeError, Counter().subtract, {}, {}) self.assertRaises(TypeError, Counter.subtract) -class TestOrderedDict(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol):

-

- -class MyOrderedDict(OrderedDict):

- -class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):

-

- -import collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,

copy from Lib/test/test_collections.py copy to Lib/test/test_ordered_dict.py --- a/Lib/test/test_collections.py +++ b/Lib/test/test_ordered_dict.py @@ -1,1042 +1,11 @@ - -import unittest, doctest, operator -import inspect -from test import test_support -from collections import namedtuple, Counter, OrderedDict -from test import mapping_tests -import pickle, cPickle, copy -from random import randrange, shuffle -import keyword -import re -import sys -from collections import Hashable, Iterable, Iterator -from collections import Sized, Container, Callable -from collections import Set, MutableSet -from collections import Mapping, MutableMapping -from collections import Sequence, MutableSequence -# Silence deprecation warning -sets = test_support.import_module('sets', deprecated=True) - -TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests - -py273_named_tuple_pickle = '''[](#l2.27) -ccopy_reg -reconstructor -p0 -(ctest.test_collections -TestNT -p1 -c__builtin_ -tuple -p2 -(I10 -I20 -I30 -tp3 -tp4 -Rp5 -ccollections -OrderedDict -p6 -((lp7 -(lp8 -S'x' -p9 -aI10 -aa(lp10 -S'y' -p11 -aI20 -aa(lp12 -S'z' -p13 -aI30 -aatp14 -Rp15 -b. -''' - -class TestNamedTuple(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -class ABCTestCase(unittest.TestCase): -

-

-

-

-

-

-

-

-

- -class TestOneTrickPonyABCs(ABCTestCase): -

-

-

-

-

-

-

-

-

- -class WithSet(MutableSet): -

-

-

-

-

-

- -class TestCollectionABCs(ABCTestCase): -

+import copy +import pickle +from random import shuffle +import unittest +from collections import OrderedDict +from collections import MutableMapping +from test import mapping_tests, test_support

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -class TestCounter(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

class TestOrderedDict(unittest.TestCase): @@ -1315,15 +284,10 @@ class SubclassMappingTests(mapping_tests d = self._empty_mapping() self.assertRaises(KeyError, d.popitem) -import collections def test_main(verbose=None):

if name == "main": test_main(verbose=True)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -27,6 +27,12 @@ Library