X Tutup
Skip to content

Commit cf7806c

Browse files
committed
make MatchesIterator test more succinct (thanks Andreas)
1 parent f874691 commit cf7806c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

bpython/test/test_repl.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import unittest
2+
import itertools
3+
24
from bpython import repl
35

46

@@ -62,13 +64,8 @@ def test_MatchesIterator(self):
6264
# should be falsey before we enter (i.e. 'not active')
6365
self.assertEqual(bool(matches_iterator), False)
6466

65-
matched = []
66-
for i, x in enumerate(matches_iterator):
67-
matched.append(x)
68-
if i == 8:
69-
break
70-
71-
self.assertEqual(matched, matches * 3)
67+
slice = itertools.islice(matches_iterator, 0, 9)
68+
self.assertEqual(list(slice),matches * 3)
7269

7370
# should be truthy once we have an active match
7471
self.assertEqual(bool(matches_iterator), True)

0 commit comments

Comments
 (0)
X Tutup