Skip to content

Commit

Permalink
Update based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Jan 4, 2024
1 parent 793ac7e commit 3959390
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
24 changes: 0 additions & 24 deletions tests/unit_tests/scheduler/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,6 @@ def mock_driver():
return MockDriver


class MockSemaphore(asyncio.Semaphore):
def __init__(self, value: int):
super().__init__(value)
self._mock_locked = asyncio.Future()
self._mock_unlocked = asyncio.Future()

async def acquire(self) -> Coroutine[Any, Any, Literal[True]]:
if self._mock_locked.done():
self._mock_locked = asyncio.Future()
self._mock_locked.set_result(True)
return await super().acquire()

def release(self) -> None:
if self._mock_unlocked.done():
self._mock_unlocked = asyncio.Future()
self._mock_unlocked.set_result(True)
return super().release()


@pytest.fixture
def mock_semaphore():
return MockSemaphore


class MockEvent(asyncio.Event):
def __init__(self):
self._mock_waited = asyncio.Future()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/scheduler/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def test_job_call(
job.started.set()
job.returncode.set_result(return_code)

await job._submit_and_run_once(asyncio.Semaphore(1))
await job._submit_and_run_once(asyncio.Semaphore())

await assert_scheduler_events(
scheduler,
Expand Down

0 comments on commit 3959390

Please sign in to comment.