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.
This commit is contained in:
洛水居室 2023-05-09 16:20:56 +08:00 committed by GitHub
parent 912a41fe45
commit 009f74839f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -4,3 +4,4 @@ GENSHIN_PLAYER_ID=
STARRAIL_PLAYER_ID= STARRAIL_PLAYER_ID=
# STOKEN= # STOKEN=
# LOGIN_TICKET= # LOGIN_TICKET=
# TEST_BUILD=

View File

@ -71,3 +71,9 @@ def stoken() -> Optional[str]: # skipcq: PY-D0003
def login_ticket() -> Optional[str]: # skipcq: PY-D0003 def login_ticket() -> Optional[str]: # skipcq: PY-D0003
_login_ticket = os.environ.get("LOGIN_TICKET") _login_ticket = os.environ.get("LOGIN_TICKET")
return _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

View File

@ -1,5 +1,9 @@
import os 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 assert os.system("python setup.py") == 0 # pragma: no cover