Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Convert Linearizer tests from inlineCallbacks to async #12353

Merged
merged 9 commits into from
Apr 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tests/util/test_linearizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class LinearizerTestCase(unittest.TestCase):
@defer.inlineCallbacks
def test_linearizer(self):
"""Tests that a task is queued up behind an earlier task."""
linearizer = Linearizer()

key = object()
Expand All @@ -44,6 +45,10 @@ def test_linearizer(self):

@defer.inlineCallbacks
def test_linearizer_is_queued(self):
"""Tests `Linearizer.is_queued`.

Runs through the same scenario as `test_linearizer`.
"""
linearizer = Linearizer()

key = object()
Expand Down Expand Up @@ -75,8 +80,10 @@ def test_linearizer_is_queued(self):
self.assertFalse(linearizer.is_queued(key))

def test_lots_of_queued_things(self):
# we have one slow thing, and lots of fast things queued up behind it.
# it should *not* explode the stack.
"""Tests lots of fast things queued up behind a slow thing.

The stack should *not* explode when the fast thing completes.
"""
linearizer = Linearizer()

@defer.inlineCallbacks
Expand All @@ -97,6 +104,7 @@ def func(i, sleep=False):

@defer.inlineCallbacks
def test_multiple_entries(self):
"""Tests a `Linearizer` with a concurrency above 1."""
limiter = Linearizer(max_count=3)

key = object()
Expand Down Expand Up @@ -143,6 +151,7 @@ def test_multiple_entries(self):

@defer.inlineCallbacks
def test_cancellation(self):
"""Tests cancellation while waiting for a `Linearizer`."""
linearizer = Linearizer()

key = object()
Expand Down