Skip to content

Commit

Permalink
make global; try changing parent by one level
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Apr 28, 2024
1 parent 05eff25 commit 411c056
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/nwbinspector/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .utils import is_module_installed, get_package_version


TESTING_CONFIG_FILE_PATH = Path(__file__).parent.parent / "tests" / "testing_config.json"

def check_streaming_tests_enabled() -> Tuple[bool, Optional[str]]:
"""
General purpose helper for determining if the testing environment can support S3 DANDI streaming.
Expand Down Expand Up @@ -49,13 +51,11 @@ def check_streaming_tests_enabled() -> Tuple[bool, Optional[str]]:

def load_testing_config() -> dict:
"""Helper function for loading the testing configuration file as a dictionary."""
test_config_file_path = Path(__file__).parent.parent.parent / "tests" / "testing_config.json"

# This error would only occur if someone installed a previous version
# directly from GitHub and then updated the branch/commit in-place
if not test_config_file_path.exists(): # pragma: no cover
if not TESTING_CONFIG_FILE_PATH.exists(): # pragma: no cover
raise FileNotFoundError(
f"The testing configuration file not found at the location '{test_config_file_path}'! "
f"The testing configuration file not found at the location '{TESTING_CONFIG_FILE_PATH}'! "
"Please try reinstalling the package."
)

Expand All @@ -67,15 +67,13 @@ def load_testing_config() -> dict:

def update_testing_config(key: str, value):
"""Update a key/value pair in the testing configuration file through the API."""
test_config_file_path = Path(__file__).parent.parent.parent / "tests" / "testing_config.json"

testing_config = load_testing_config()

if key not in testing_config:
raise KeyError("Updating the testing configuration file via the API is only possible for the pre-defined keys!")
testing_config[key] = value

with open(file=test_config_file_path, mode="w") as file:
with open(file=TESTING_CONFIG_FILE_PATH, mode="w") as file:
json.dump(testing_config, file)


Expand Down

0 comments on commit 411c056

Please sign in to comment.