From 166e48bfc5806d45ee11f3e8ee1246f11d124d0b Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 3 Oct 2022 16:50:30 -0400 Subject: [PATCH] gh-94808: Coverage: Check picklablability of calliter (GH-95923) (cherry picked from commit cfbc7dd91059cb663c7fe13c661665943495ed7f) Co-authored-by: Michael Droettboom --- Lib/test/test_iter.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py index 554f602f6252c0..acbdcb5f302060 100644 --- a/Lib/test/test_iter.py +++ b/Lib/test/test_iter.py @@ -81,6 +81,16 @@ class BadIterableClass: def __iter__(self): raise ZeroDivisionError +class CallableIterClass: + def __init__(self): + self.i = 0 + def __call__(self): + i = self.i + self.i = i + 1 + if i > 100: + raise IndexError # Emergency stop + return i + # Main test suite class TestCase(unittest.TestCase): @@ -237,16 +247,7 @@ def __iter__(self): # Test two-argument iter() with callable instance def test_iter_callable(self): - class C: - def __init__(self): - self.i = 0 - def __call__(self): - i = self.i - self.i = i + 1 - if i > 100: - raise IndexError # Emergency stop - return i - self.check_iterator(iter(C(), 10), list(range(10)), pickle=False) + self.check_iterator(iter(CallableIterClass(), 10), list(range(10)), pickle=True) # Test two-argument iter() with function def test_iter_function(self): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy