Skip to content

Commit

Permalink
tests: models: find model script paths relative to psyneulink root (#…
Browse files Browse the repository at this point in the history
…3141)

Searching for the model scripts starting from the test directory can
fail if psyneulink is not installed locally. Starting from the
psyneulink root directory should be more reliable across install types.
  • Loading branch information
kmantel authored Dec 12, 2024
1 parent 1ea4407 commit af83af0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions tests/models/test_documentation_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
import os
import pathlib
import runpy
import sys

Expand Down Expand Up @@ -80,23 +80,15 @@ def test_documentation_models(
additional_args,
variant,
):
models_dir = os.path.join(
os.path.dirname(__file__),
'..',
'..',
'psyneulink',
'library',
'models'
)
model_file = os.path.join(models_dir, f'{model_name}.py')
models_dir = pathlib.Path(pnl.__file__).parent.joinpath('library', 'models')
model_file = models_dir.joinpath(f'{model_name}.py')
old_argv = sys.argv
sys.argv = [model_file] + additional_args
script_globals = runpy.run_path(model_file)
sys.argv = old_argv

suffix = f'-{variant}' if variant is not None else ''
expected_results_file = os.path.join(
models_dir,
expected_results_file = models_dir.joinpath(
'results',
f'{model_name}-{composition_name}{suffix}.json'
)
Expand Down

0 comments on commit af83af0

Please sign in to comment.