gh-101277: Isolate itertools, add group and _grouper types to module state (#101302)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Erlend E. Aasland 2023-02-01 12:41:30 +01:00 committed by GitHub
parent cc407b9de6
commit 2b3e02a705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 173 additions and 111 deletions

View file

@ -1694,6 +1694,38 @@ class TestBasicOps(unittest.TestCase):
gc.collect()
self.assertTrue(gc.is_tracked(next(it)))
@support.cpython_only
def test_immutable_types(self):
from itertools import _grouper, _tee, _tee_dataobject
dataset = (
accumulate,
batched,
chain,
combinations,
combinations_with_replacement,
compress,
count,
cycle,
dropwhile,
filterfalse,
groupby,
_grouper,
islice,
pairwise,
permutations,
product,
repeat,
starmap,
takewhile,
_tee,
_tee_dataobject,
zip_longest,
)
for tp in dataset:
with self.subTest(tp=tp):
with self.assertRaisesRegex(TypeError, "immutable"):
tp.foobar = 1
class TestExamples(unittest.TestCase):