Skip to content

Commit

Permalink
test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Sep 15, 2017
1 parent 8c54875 commit 383ff17
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/tests/test_code_in_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ def run_py(path):
os.chdir(py_dir)

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

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

args = ["python", py_path]
subprocess.check_output(args)
Expand Down

0 comments on commit 383ff17

Please sign in to comment.