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

Unified Diff: Lib/test/test_collections.py

Issue 26915: Test identity first in membership operation of ItemsView, ValuesView and Sequence in collections.abc
Patch Set: Created 3 years, 11 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/_collections_abc.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_collections.py Thu May 05 11:14:06 2016 +0300
+++ b/Lib/test/test_collections.py Thu May 05 18:28:34 2016 +0800
@@ -1082,17 +1082,22 @@
class CustomSequence(list):
def __contains__(self, value):
return Sequence.__contains__(self, value)
+ def index(self, value, start=0, stop=None):
+ return Sequence.index(self, value, start, stop)
+ def count(self, value):
+ return Sequence.count(self, value)
nan = float('nan')
obj = CustomEqualObject()
- containers = [
- CustomSequence([nan, obj]),
- ItemsView({1: nan, 2: obj}),
- ValuesView({1: nan, 2: obj})
- ]
+ seq = CustomSequence([nan, obj, nan])
+ containers = [seq, ItemsView({1: nan, 2: obj}), ValuesView({1: nan, 2: obj})]
storchaka 2016/06/03 20:06:20 Line is too long.
for container in containers:
for elem in container:
self.assertIn(elem, container)
+ self.assertEqual(seq.index(nan), 0)
storchaka 2016/06/03 20:06:20 Would be worth to add a test for seq.index(nan, 1)
+ self.assertEqual(seq.index(obj), 1)
+ self.assertEqual(seq.count(nan), 2)
+ self.assertEqual(seq.count(obj), 1)
def assertSameSet(self, s1, s2):
# coerce both to a real set then check equality
« no previous file with comments | « Lib/_collections_abc.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+