Skip to content

Commit 40d039a

Browse files
committed
Don't allow environment variables to be set during test runs
1 parent 6256e0c commit 40d039a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

array_api_strict/_flags.py

+7
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ def __exit__(self, exc_type, exc_value, traceback):
293293

294294
# Private functions
295295

296+
ENVIRONMENT_VARIABLES = [
297+
"ARRAY_API_STRICT_API_VERSION",
298+
"ARRAY_API_STRICT_BOOLEAN_INDEXING",
299+
"ARRAY_API_STRICT_DATA_DEPENDENT_SHAPES",
300+
"ARRAY_API_STRICT_ENABLED_EXTENSIONS",
301+
]
302+
296303
def set_flags_from_environment():
297304
if "ARRAY_API_STRICT_API_VERSION" in os.environ:
298305
set_array_api_strict_flags(

array_api_strict/tests/conftest.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
from .._flags import reset_array_api_strict_flags
1+
import os
2+
3+
from .._flags import reset_array_api_strict_flags, ENVIRONMENT_VARIABLES
24

35
import pytest
46

7+
def pytest_sessionstart(session):
8+
for env_var in ENVIRONMENT_VARIABLES:
9+
if env_var in os.environ:
10+
pytest.exit(f"ERROR: {env_var} is set. array-api-strict environment variables must not be set when the tests are run.")
11+
512
@pytest.fixture(autouse=True)
613
def reset_flags():
714
reset_array_api_strict_flags()

0 commit comments

Comments
 (0)