Revert debug changes and improve TEST_WITH_OPT_DEPS handling

This commit is contained in:
Hinrich Mahler 2024-12-31 10:33:12 +01:00
parent 9cabf0e03b
commit 92851a4c7b
4 changed files with 17 additions and 13 deletions

View file

@ -27,6 +27,9 @@ def env_var_2_bool(env_var: object) -> bool:
return env_var.lower().strip() == "true" return env_var.lower().strip() == "true"
GITHUB_ACTION = os.getenv("GITHUB_ACTION", "") GITHUB_ACTION: bool = env_var_2_bool(os.getenv("GITHUB_ACTION", "false"))
TEST_WITH_OPT_DEPS = env_var_2_bool(os.getenv("TEST_WITH_OPT_DEPS", "false")) TEST_WITH_OPT_DEPS: bool = env_var_2_bool(os.getenv("TEST_WITH_OPT_DEPS", "")) or (
RUN_TEST_OFFICIAL = env_var_2_bool(os.getenv("TEST_OFFICIAL")) # on local setups, we usually want to test with optional dependencies
not GITHUB_ACTION
)
RUN_TEST_OFFICIAL: bool = env_var_2_bool(os.getenv("TEST_OFFICIAL"))

View file

@ -21,12 +21,13 @@ import calendar
import contextlib import contextlib
import datetime as dtm import datetime as dtm
import logging import logging
import platform
import time import time
import pytest import pytest
from telegram.ext import ApplicationBuilder, CallbackContext, ContextTypes, Defaults, Job, JobQueue from telegram.ext import ApplicationBuilder, CallbackContext, ContextTypes, Defaults, Job, JobQueue
from tests.auxil.envvars import TEST_WITH_OPT_DEPS from tests.auxil.envvars import GITHUB_ACTION, TEST_WITH_OPT_DEPS
from tests.auxil.pytest_classes import make_bot from tests.auxil.pytest_classes import make_bot
from tests.auxil.slots import mro_slots from tests.auxil.slots import mro_slots
@ -64,13 +65,13 @@ class TestNoJobQueue:
Job(None) Job(None)
# @pytest.mark.skipif( @pytest.mark.skipif(
# not TEST_WITH_OPT_DEPS, reason="Only relevant if the optional dependency is installed" not TEST_WITH_OPT_DEPS, reason="Only relevant if the optional dependency is installed"
# ) )
# @pytest.mark.skipif( @pytest.mark.skipif(
# bool(GITHUB_ACTION and platform.system() in ["Windows", "Darwin"]), GITHUB_ACTION and platform.system() in ["Windows", "Darwin"],
# reason="On Windows & MacOS precise timings are not accurate.", reason="On Windows & MacOS precise timings are not accurate.",
# ) )
@pytest.mark.flaky(10, 1) # Timings aren't quite perfect @pytest.mark.flaky(10, 1) # Timings aren't quite perfect
class TestJobQueue: class TestJobQueue:
result = 0 result = 0

View file

@ -142,7 +142,7 @@ class TestBaseRateLimiter:
not TEST_WITH_OPT_DEPS, reason="Only relevant if the optional dependency is installed" not TEST_WITH_OPT_DEPS, reason="Only relevant if the optional dependency is installed"
) )
@pytest.mark.skipif( @pytest.mark.skipif(
bool(GITHUB_ACTION and platform.system() == "Darwin"), GITHUB_ACTION and platform.system() == "Darwin",
reason="The timings are apparently rather inaccurate on MacOS.", reason="The timings are apparently rather inaccurate on MacOS.",
) )
@pytest.mark.flaky(10, 1) # Timings aren't quite perfect @pytest.mark.flaky(10, 1) # Timings aren't quite perfect

View file

@ -154,7 +154,7 @@ def inline_results():
BASE_GAME_SCORE = 60 # Base game score for game tests BASE_GAME_SCORE = 60 # Base game score for game tests
xfail = pytest.mark.xfail( xfail = pytest.mark.xfail(
bool(GITHUB_ACTION), # This condition is only relevant for github actions game tests. GITHUB_ACTION, # This condition is only relevant for github actions game tests.
reason=( reason=(
"Can fail due to race conditions when multiple test suites " "Can fail due to race conditions when multiple test suites "
"with the same bot token are run at the same time" "with the same bot token are run at the same time"