From c64b731cfb03836857ded16367f649356782c1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Wed, 4 Dec 2024 19:32:17 +0100 Subject: [PATCH] v2.26.4 --- satella/coding/generators.py | 2 +- tests/test_coding/test_iterators.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/satella/coding/generators.py b/satella/coding/generators.py index 3b834c82..2e96f53c 100644 --- a/satella/coding/generators.py +++ b/satella/coding/generators.py @@ -76,7 +76,7 @@ class RunActionAfterGeneratorCompletes(tp.Generator, metaclass=ABCMeta): """This will run when this generator throws any exception. Override it.""" -def run_when_generator_completes(gen: tp.Generator, call_on_done: tp.Callable +def run_when_generator_completes(gen: tp.Generator, call_on_done: tp.Callable, *args, **kwargs) -> RunActionAfterGeneratorCompletes: """ Return the generator with call_on_done to be called on when it finishes diff --git a/tests/test_coding/test_iterators.py b/tests/test_coding/test_iterators.py index 82459e3c..73852f58 100644 --- a/tests/test_coding/test_iterators.py +++ b/tests/test_coding/test_iterators.py @@ -140,7 +140,7 @@ class TestIterators(unittest.TestCase): self.assertFalse(called) - def test_run_when_generator_closed_failure(self): + def test_run_when_generator_failure(self): called = False def generator(): @@ -161,10 +161,9 @@ class TestIterators(unittest.TestCase): called = True gen = Inner(generator()) - a = next(gen) - gen.close() - self.assertRaises(StopIteration, next, gen) - self.assertFalse(called) + for i in gen: + pass + self.assertTrue(called) def test_list_wrapper_iterator_contains(self): -- GitLab