Skip to content

Commit

Permalink
Add tests for run_python_script_in_terminal()
Browse files Browse the repository at this point in the history
  • Loading branch information
jitseniesen committed Jun 10, 2016
1 parent b05f470 commit 1289820
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spyderlib/utils/tests/test_programs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2009- The Spyder Development Team
# Licensed under the terms of the MIT License

"""Tests for programs.py"""

import time

import pytest

from spyderlib.utils.programs import run_python_script_in_terminal

def test_run_python_script_in_terminal(tmpdir):
scriptpath = tmpdir.join('write-done.py')
outfilepath = tmpdir.join('out.txt')
script = ("with open('out.txt', 'w') as f:\n"
" f.write('done')\n")
scriptpath.write(script)
run_python_script_in_terminal(scriptpath.strpath, tmpdir.strpath, '',
False, False, '')
time.sleep(1) # wait for script to finish
res = outfilepath.read()
assert res == 'done'

def test_run_python_script_in_terminal_with_wdir_empty(tmpdir):
scriptpath = tmpdir.join('write-done.py')
outfilepath = tmpdir.join('out.txt')
script = ("with open('{}', 'w') as f:\n"
" f.write('done')\n").format(outfilepath.strpath)
scriptpath.write(script)
run_python_script_in_terminal(scriptpath.strpath, '', '', False, False, '')
time.sleep(1) # wait for script to finish
res = outfilepath.read()
assert res == 'done'


if __name__ == '__main__':
pytest.main()

0 comments on commit 1289820

Please sign in to comment.