-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for run_python_script_in_terminal()
- Loading branch information
1 parent
b05f470
commit 1289820
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|