Skip to content

Commit

Permalink
Fix the new test so that it passes for Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Azureblade3808 committed Sep 29, 2024
1 parent d6d5aac commit 9a444f0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions deferrer_tests/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,26 @@ def unraisablehook(args: sys.UnraisableHookArgs, /) -> None:
def test__work_in_generator_function() -> None:
""" """

def f():
# Makes the function a generator function.
yield
if sys.version_info >= (3, 12):

# Should cause a `ZeroDivisionError` in deferred actions.
defer and 0 / 0
def f():
# Makes the function a generator function.
yield

# Should cause a `ZeroDivisionError` in deferred actions.
defer and 0 / 0

else:

if sys.version_info < (3, 12):
from deferrer import defer_scope

f = defer_scope(f)
def f():
with defer_scope():
# Makes the function a generator function.
yield

# Should cause a `ZeroDivisionError` in deferred actions.
defer and 0 / 0

with pytest.raises(Exception) as exc_info:
e = None
Expand Down

0 comments on commit 9a444f0

Please sign in to comment.