From 9156618a56d635bb51261d019a3703a1b4e3b588 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Fri, 14 Feb 2020 16:28:41 -0500 Subject: Fixed bug where pyscripts could edit cmd2.Cmd.py_locals dictionary. Fixed bug where cmd2 set sys.path[0] for a pyscript to its cwd instead of the script's directory. Fixed bug where sys.path was not being restored after a pyscript ran. Setting the following pyscript variables: __name__: __main__ __file__: script path (as typed) Removed do_py.run() function since it didn't handle arguments and offered no benefit over run_pyscript. --- tests/test_run_pyscript.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/test_run_pyscript.py') diff --git a/tests/test_run_pyscript.py b/tests/test_run_pyscript.py index d717758c..811fd688 100644 --- a/tests/test_run_pyscript.py +++ b/tests/test_run_pyscript.py @@ -117,10 +117,9 @@ def test_run_pyscript_stop(base_app, request): stop = base_app.onecmd_plus_hooks('run_pyscript {}'.format(python_script)) assert stop -def test_run_pyscript_run(base_app, request): +def test_run_pyscript_environment(base_app, request): test_dir = os.path.dirname(request.module.__file__) - python_script = os.path.join(test_dir, 'pyscript', 'run.py') - expected = 'I have been run' + python_script = os.path.join(test_dir, 'pyscript', 'environment.py') + out, err = run_cmd(base_app, 'run_pyscript {}'.format(python_script)) - out, err = run_cmd(base_app, "run_pyscript {}".format(python_script)) - assert expected in out + assert out[0] == "PASSED" -- cgit v1.2.1