cpython: 8d9a0540adf9 (original) (raw)

--- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1,16 +1,19 @@ """Unit tests for collections.py.""" -import unittest, doctest, operator -from test.support import TESTFN, forget, unlink -import inspect +import collections +import copy +import doctest +import keyword +import operator +import pickle +from random import choice, randrange +import re +import string +import sys from test import support +import unittest + from collections import namedtuple, Counter, OrderedDict, _count_elements -from test import mapping_tests -import pickle, copy -from random import randrange, shuffle -import keyword -import re -import sys from collections import UserDict from collections import ChainMap from collections.abc import Hashable, Iterable, Iterator @@ -281,8 +284,7 @@ class TestNamedTuple(unittest.TestCase): # n = 5000 n = 254 # SyntaxError: more than 255 arguments:

@@ -1281,309 +1283,13 @@ class TestCounter(unittest.TestCase): ################################################################################ -### OrderedDict -################################################################################ - -class TestOrderedDict(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol):

-

- -class MyOrderedDict(OrderedDict):

- -class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):

-

- - -################################################################################

Run tests

################################################################################ -import doctest, 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,1288 +1,13 @@ -"""Unit tests for collections.py.""" - -import unittest, doctest, operator -from test.support import TESTFN, forget, unlink -import inspect -from test import support -from collections import namedtuple, Counter, OrderedDict, _count_elements -from test import mapping_tests -import pickle, copy -from random import randrange, shuffle -import keyword -import re +import contextlib +import copy +import pickle +from random import shuffle import sys -from collections import UserDict -from collections import ChainMap -from collections.abc import Hashable, Iterable, Iterator -from collections.abc import Sized, Container, Callable -from collections.abc import Set, MutableSet -from collections.abc import Mapping, MutableMapping, KeysView, ItemsView -from collections.abc import Sequence, MutableSequence -from collections.abc import ByteString - - -################################################################################ -### ChainMap (helper class for configparser and the string module) -################################################################################ - -class TestChainMap(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

- - -################################################################################ -### Named Tuples -################################################################################ - -TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests - -class TestNamedTuple(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -

-

-

- - -################################################################################ -### Abstract Base Classes -################################################################################ - -class ABCTestCase(unittest.TestCase): -

-

-

-

-

-

-

-

-

- -class TestOneTrickPonyABCs(ABCTestCase): -

-

-

-

-

-

-

-

-

- -class WithSet(MutableSet): -

-

-

-

-

-

- -class TestCollectionABCs(ABCTestCase): -

+import unittest +from collections import OrderedDict +from collections.abc import MutableMapping +from test import mapping_tests, support

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- -################################################################################ -### Counter -################################################################################ - -class CounterSubclassWithSetItem(Counter):

- -class CounterSubclassWithGet(Counter):

- -class TestCounter(unittest.TestCase): -

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- - -################################################################################ -### OrderedDict -################################################################################ class TestOrderedDict(unittest.TestCase): @@ -1573,20 +298,5 @@ class SubclassMappingTests(mapping_tests self.assertRaises(KeyError, d.popitem) -################################################################################ -### Run tests -################################################################################ - -import doctest, collections - -def test_main(verbose=None):

- - if name == "main":

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -694,6 +694,9 @@ IDLE Tests ----- +- Issue #25616: Tests for OrderedDict are extracted from test_collections