def test_run_python_script_in_terminal_with_wdir_empty(tmpdir, qtbot): 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, '') qtbot.wait(1000) # wait for script to finish res = outfilepath.read() assert res == 'done'
def test_run_python_script_in_terminal_with_wdir_empty(tmpdir, qtbot): 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, '') qtbot.wait(1000) # wait for script to finish res = outfilepath.read() assert res == 'done'
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(scriptpath, qtbot): """ Test running a Python script in an external terminal when specifying explicitly the working directory. """ # Run the script outfilepath = osp.join(scriptpath.dirname, 'out.txt') run_python_script_in_terminal(scriptpath.strpath, scriptpath.dirname, '', False, False, '') qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=10000) # Assert the result. with open(outfilepath, 'r') as txtfile: res = txtfile.read() assert res == 'done'
def test_run_python_script_in_terminal_with_wdir_empty(scriptpath, qtbot): """ Test running a Python script in an external terminal without specifying the working directory. """ # Run the script. if sys.platform == 'darwin': outfilepath = osp.join(osp.expanduser('~'), 'out.txt') else: outfilepath = osp.join(os.getcwd(), 'out.txt') run_python_script_in_terminal(scriptpath.strpath, '', '', False, False, '') qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=10000) # Assert the result. with open(outfilepath, 'r') as txtfile: res = txtfile.read() assert res == 'done'