Skip to content

Commit

Permalink
Made notebook tests run with notebook path as working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelClerx committed Jan 6, 2025
1 parent 93c85cd commit 7ccd8fb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def list_notebooks(root, recursive=True, ignore_list=None, notebooks=None):

def test_notebook(path):
"""
Tests a notebook in a subprocess, exists if it doesn't finish.
Tests a notebook in a subprocess, exits if it doesn't finish.
"""
import nbconvert
import pints
Expand All @@ -442,7 +442,7 @@ def test_notebook(path):

# Load notebook, convert to python
e = nbconvert.exporters.PythonExporter()
code, __ = e.from_filename(path)
code, _ = e.from_filename(path)

# Remove coding statement, if present
code = '\n'.join([x for x in code.splitlines() if x[:9] != '# coding'])
Expand All @@ -455,7 +455,8 @@ def test_notebook(path):
cmd = [sys.executable, '-c', code]
try:
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,
cwd=os.path.dirname(path)
)
stdout, stderr = p.communicate()
# TODO: Use p.communicate(timeout=3600)
Expand Down

0 comments on commit 7ccd8fb

Please sign in to comment.