diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2023-12-16 15:13:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-16 15:13:50 (GMT) |
commit | 1583c40be938d2caf363c126976bc8757df90b13 (patch) | |
tree | 13c6360133c2dcb3d58c255fba500e9090e383a5 /Lib/test | |
parent | fe479fb8a979894224a4d279d1e46a5cdb108fa4 (diff) | |
download | cpython-1583c40be938d2caf363c126976bc8757df90b13.zip cpython-1583c40be938d2caf363c126976bc8757df90b13.tar.gz cpython-1583c40be938d2caf363c126976bc8757df90b13.tar.bz2 |
gh-113202: Add a strict option to itertools.batched() (gh-113203)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_itertools.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 705e880..9af0730 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -187,7 +187,11 @@ class TestBasicOps(unittest.TestCase): [('A', 'B'), ('C', 'D'), ('E', 'F'), ('G',)]) self.assertEqual(list(batched('ABCDEFG', 1)), [('A',), ('B',), ('C',), ('D',), ('E',), ('F',), ('G',)]) + self.assertEqual(list(batched('ABCDEF', 2, strict=True)), + [('A', 'B'), ('C', 'D'), ('E', 'F')]) + with self.assertRaises(ValueError): # Incomplete batch when strict + list(batched('ABCDEFG', 3, strict=True)) with self.assertRaises(TypeError): # Too few arguments list(batched('ABCDEFG')) with self.assertRaises(TypeError): |