diff --git a/tests/test_create_remove_wrapper.py b/tests/test_create_remove_wrapper.py index 859568ddcaf1eb16d3af36af8b13f081f07b119f..09ae0fc11a94d63f92974f70bc7bb42b2982ecd4 100755 --- a/tests/test_create_remove_wrapper.py +++ b/tests/test_create_remove_wrapper.py @@ -126,6 +126,40 @@ def test_create_python_wrapper(): assert got == expect +def test_create_pythonw_wrapper(): + """Test creation of a wrapper script for a python script which + uses pythonw as the interpreter (for GUI apps on macOS). + """ + hashbangs = [ + '#!/bin/bash /usr/bin/pythonw', + '#!/usr/bin/pythonw', + '#!/usr/bin/env pythonw'] + with temp_fsldir() as (fsldir, wrapperdir): + + script_path = op.join(fsldir, 'bin', 'test_script') + wrapper_path = op.join(wrapperdir, 'test_script') + + touch(script_path) + + for hb in hashbangs: + with open(script_path, 'wt') as f: + f.write(hb + '\n') + f.write('print("hello")\n') + + expect = tw.dedent(f""" + #!/usr/bin/env bash + {fsldir}/bin/pythonw -I {script_path} "$@" + """).strip() + + run(f'{CREATE_WRAPPER} test_script') + + assert op.exists(wrapper_path) + with open(wrapper_path, 'rt') as f: + got = f.read().strip() + + assert got == expect + + def test_create_other_wrapper(): """Test creation of a wrapper script for a non-python executable.""" with temp_fsldir() as (fsldir, wrapperdir): @@ -151,6 +185,7 @@ def test_create_other_wrapper(): assert got == expect + def test_permissions_preserved(): """Test that wrapper script has same permissions as wrapped script.""" with temp_fsldir() as (fsldir, wrapperdir):