Skip to content

Commit

Permalink
Skip tests requiring time-machine on implementation other than CPython
Browse files Browse the repository at this point in the history
PyPy and time machine are not compatible at the moment.
  • Loading branch information
agronholm committed Nov 26, 2023
1 parent e071f5d commit 3a8977c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test = [
"pytest >= 7.4.0",
"pytest-lazy-fixture",
"pytest-mock",
"time-machine >= 2.13.0",
"time-machine >= 2.13.0; python_implementation == 'CPython'",
"uwsgi; python_implementation == 'CPython' and platform_system == 'Linux'",
]
doc = [
Expand Down
19 changes: 17 additions & 2 deletions tests/test_datastores.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

import platform
from contextlib import AsyncExitStack, asynccontextmanager
from datetime import datetime, timedelta, timezone
from logging import Logger
from typing import AsyncGenerator
from typing import TYPE_CHECKING, AsyncGenerator

import anyio
import pytest
from anyio import CancelScope
from time_machine import TimeMachineFixture

from apscheduler import (
CoalescePolicy,
Expand All @@ -29,6 +29,9 @@
from apscheduler.abc import DataStore, EventBroker
from apscheduler.triggers.date import DateTrigger

if TYPE_CHECKING:
from time_machine import TimeMachineFixture

pytestmark = pytest.mark.anyio


Expand Down Expand Up @@ -177,6 +180,10 @@ async def test_remove_schedules(
assert not events


@pytest.mark.skipif(
platform.python_implementation() != "CPython",
reason="time-machine is not available",
)
async def test_acquire_release_schedules(
datastore: DataStore, schedules: list[Schedule], time_machine: TimeMachineFixture
) -> None:
Expand Down Expand Up @@ -269,6 +276,10 @@ async def test_release_two_schedules_at_once(datastore: DataStore) -> None:
assert len(remaining) == 2


@pytest.mark.skipif(
platform.python_implementation() != "CPython",
reason="time-machine is not available",
)
async def test_acquire_schedules_lock_timeout(
datastore: DataStore,
schedules: list[Schedule],
Expand Down Expand Up @@ -439,6 +450,10 @@ async def test_job_release_cancelled(datastore: DataStore) -> None:
assert not await datastore.get_job_result(acquired[0].id)


@pytest.mark.skipif(
platform.python_implementation() != "CPython",
reason="time-machine is not available",
)
async def test_acquire_jobs_lock_timeout(
datastore: DataStore, time_machine: TimeMachineFixture
) -> None:
Expand Down

0 comments on commit 3a8977c

Please sign in to comment.