From 009f74839fedf15bc3904e4c4d17559097c17529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 9 May 2023 16:20:56 +0800 Subject: [PATCH] :white_check_mark: Add support for TEST_BUILD environment variable In the `test_build` function, added support for the TEST_BUILD environment variable. Now, if the variable is set to True, the `test_build` function will run; otherwise, it will skip the test and output a related message. Additionally, introduced a new pytest fixture `if_test_build` to check if the test is enabled. --- tests/.env.example | 3 ++- tests/conftest.py | 6 ++++++ tests/test_setup.py | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/.env.example b/tests/.env.example index e0ce210..60a0511 100644 --- a/tests/.env.example +++ b/tests/.env.example @@ -3,4 +3,5 @@ ACCOUNT_ID= GENSHIN_PLAYER_ID= STARRAIL_PLAYER_ID= # STOKEN= -# LOGIN_TICKET= \ No newline at end of file +# LOGIN_TICKET= +# TEST_BUILD= \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index c70f944..86fffb5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -71,3 +71,9 @@ def stoken() -> Optional[str]: # skipcq: PY-D0003 def login_ticket() -> Optional[str]: # skipcq: PY-D0003 _login_ticket = os.environ.get("LOGIN_TICKET") return _login_ticket + + +@pytest.fixture(scope="session") +def if_test_build() -> bool: # skipcq: PY-D0003 + _test_build = bool(os.environ.get("TEST_BUILD", False)) + return _test_build diff --git a/tests/test_setup.py b/tests/test_setup.py index 557ac5a..2e48f39 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -1,5 +1,9 @@ import os +import pytest -def test_build(): + +def test_build(if_test_build: bool): + if not if_test_build: + pytest.skip("TEST_BUILD not enabled") assert os.system("python setup.py") == 0 # pragma: no cover