Skip to content

Commit 383ff17

Browse files
committed
test scripts
1 parent 8c54875 commit 383ff17

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

code/tests/test_code_in_scripts.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ def run_py(path):
1212
os.chdir(py_dir)
1313

1414
with open(path, 'r') as f:
15-
content = f.read()
15+
content = [line for line in f.readlines()
16+
if not line.startswith('plt.tight_layout()')]
1617

1718
with open(path, 'w') as f:
18-
set_backend = "import matplotlib\nmatplotlib.use('Agg')\n"
19-
content = set_backend + content
20-
f.write(content)
19+
set_backend = "\n\nimport matplotlib\nmatplotlib.use('Agg')\n\n"
20+
content.insert(2, set_backend)
21+
f.write('\n'.join(content))
2122

2223
args = ["python", py_path]
2324
subprocess.check_output(args)

0 commit comments

Comments
 (0)