Skip to content

Commit

Permalink
improved test decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Aug 15, 2023
1 parent 5ddda24 commit 9e3ea92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/asyncio/test_retry_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,9 @@ async def __anext__(self):
await retryable.__anext__()

@pytest.mark.parametrize("yield_method", ["__anext__", "asend"])
@mock.patch("random.uniform", autospec=True, side_effect=lambda m, n: n)
@mock.patch("asyncio.sleep", autospec=True)
@pytest.mark.asyncio
async def test_yield_stream_after_deadline(self, sleep, uniform, yield_method):
async def test_yield_stream_after_deadline(self, sleep, yield_method):
"""
By default, if the deadline is hit between yields, the generator will continue.
Expand Down Expand Up @@ -828,8 +827,9 @@ async def test_yield_stream_after_deadline(self, sleep, uniform, yield_method):
await check_yield()
await no_check_yield()

@mock.patch("asyncio.sleep", autospec=True)
@pytest.mark.asyncio
async def test_generator_error_list(self):
async def test_generator_error_list(self, sleep):
"""
generator should keep history of errors seen
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,8 @@ def test___call___with_is_stream(self, sleep):
assert unpacked == [0, 1, 2, 3, 4, 5, 0, 1, 2, 3]

@pytest.mark.parametrize("yield_method", ["__next__", "send"])
@mock.patch("random.uniform", autospec=True, side_effect=lambda m, n: n)
@mock.patch("asyncio.sleep", autospec=True)
def test_yield_stream_after_deadline(self, sleep, uniform, yield_method):
def test_yield_stream_after_deadline(self, sleep, yield_method):
"""
By default, if the deadline is hit between yields, the generator will continue.
Expand Down Expand Up @@ -833,7 +832,8 @@ def test_yield_stream_after_deadline(self, sleep, uniform, yield_method):
check_yield()
no_check_yield()

def test_generator_error_list(self):
@mock.patch("asyncio.sleep", autospec=True)
def test_generator_error_list(self, sleep):
"""
generator should keep history of errors seen
"""
Expand Down

0 comments on commit 9e3ea92

Please sign in to comment.