Kaydet (Commit) abe46fd8 authored tarafından Ezio Melotti's avatar Ezio Melotti

#17766: merge with 3.3.

...@@ -50,7 +50,7 @@ from operator import length_hint ...@@ -50,7 +50,7 @@ from operator import length_hint
n = 10 n = 10
class TestInvariantWithoutMutations(unittest.TestCase): class TestInvariantWithoutMutations:
def test_invariant(self): def test_invariant(self):
it = self.it it = self.it
...@@ -77,64 +77,64 @@ class TestTemporarilyImmutable(TestInvariantWithoutMutations): ...@@ -77,64 +77,64 @@ class TestTemporarilyImmutable(TestInvariantWithoutMutations):
## ------- Concrete Type Tests ------- ## ------- Concrete Type Tests -------
class TestRepeat(TestInvariantWithoutMutations): class TestRepeat(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = repeat(None, n) self.it = repeat(None, n)
class TestXrange(TestInvariantWithoutMutations): class TestXrange(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = iter(range(n)) self.it = iter(range(n))
class TestXrangeCustomReversed(TestInvariantWithoutMutations): class TestXrangeCustomReversed(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = reversed(range(n)) self.it = reversed(range(n))
class TestTuple(TestInvariantWithoutMutations): class TestTuple(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = iter(tuple(range(n))) self.it = iter(tuple(range(n)))
## ------- Types that should not be mutated during iteration ------- ## ------- Types that should not be mutated during iteration -------
class TestDeque(TestTemporarilyImmutable): class TestDeque(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = deque(range(n)) d = deque(range(n))
self.it = iter(d) self.it = iter(d)
self.mutate = d.pop self.mutate = d.pop
class TestDequeReversed(TestTemporarilyImmutable): class TestDequeReversed(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = deque(range(n)) d = deque(range(n))
self.it = reversed(d) self.it = reversed(d)
self.mutate = d.pop self.mutate = d.pop
class TestDictKeys(TestTemporarilyImmutable): class TestDictKeys(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = dict.fromkeys(range(n)) d = dict.fromkeys(range(n))
self.it = iter(d) self.it = iter(d)
self.mutate = d.popitem self.mutate = d.popitem
class TestDictItems(TestTemporarilyImmutable): class TestDictItems(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = dict.fromkeys(range(n)) d = dict.fromkeys(range(n))
self.it = iter(d.items()) self.it = iter(d.items())
self.mutate = d.popitem self.mutate = d.popitem
class TestDictValues(TestTemporarilyImmutable): class TestDictValues(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = dict.fromkeys(range(n)) d = dict.fromkeys(range(n))
self.it = iter(d.values()) self.it = iter(d.values())
self.mutate = d.popitem self.mutate = d.popitem
class TestSet(TestTemporarilyImmutable): class TestSet(TestTemporarilyImmutable, unittest.TestCase):
def setUp(self): def setUp(self):
d = set(range(n)) d = set(range(n))
...@@ -143,7 +143,7 @@ class TestSet(TestTemporarilyImmutable): ...@@ -143,7 +143,7 @@ class TestSet(TestTemporarilyImmutable):
## ------- Types that can mutate during iteration ------- ## ------- Types that can mutate during iteration -------
class TestList(TestInvariantWithoutMutations): class TestList(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = iter(range(n)) self.it = iter(range(n))
...@@ -163,7 +163,7 @@ class TestList(TestInvariantWithoutMutations): ...@@ -163,7 +163,7 @@ class TestList(TestInvariantWithoutMutations):
self.assertEqual(length_hint(it), 0) self.assertEqual(length_hint(it), 0)
class TestListReversed(TestInvariantWithoutMutations): class TestListReversed(TestInvariantWithoutMutations, unittest.TestCase):
def setUp(self): def setUp(self):
self.it = reversed(range(n)) self.it = reversed(range(n))
...@@ -225,23 +225,5 @@ class TestLengthHintExceptions(unittest.TestCase): ...@@ -225,23 +225,5 @@ class TestLengthHintExceptions(unittest.TestCase):
self.assertEqual(list(NoneLengthHint()), list(range(10))) self.assertEqual(list(NoneLengthHint()), list(range(10)))
def test_main():
unittests = [
TestRepeat,
TestXrange,
TestXrangeCustomReversed,
TestTuple,
TestDeque,
TestDequeReversed,
TestDictKeys,
TestDictItems,
TestDictValues,
TestSet,
TestList,
TestListReversed,
TestLengthHintExceptions,
]
support.run_unittest(*unittests)
if __name__ == "__main__": if __name__ == "__main__":
test_main() unittest.main()
...@@ -119,6 +119,9 @@ Tests ...@@ -119,6 +119,9 @@ Tests
- Issue #12820: add tests for the xml.dom.minicompat module. - Issue #12820: add tests for the xml.dom.minicompat module.
Patch by John Chandler and Phil Connell. Patch by John Chandler and Phil Connell.
- Issue #17766: test_iterlen now works with unittest test discovery.
Patch by Zachary Ware.
- Issue #17690: test_time now works with unittest test discovery. - Issue #17690: test_time now works with unittest test discovery.
Patch by Zachary Ware. Patch by Zachary Ware.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment