From 25fa93a842e9c68086f1a6f31fbcc45b260edc92 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Fri, 6 Aug 2021 15:20:15 +0100
Subject: [PATCH] TEST: test createFSLWrapper with pythonw

---
 tests/test_create_remove_wrapper.py | 35 +++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tests/test_create_remove_wrapper.py b/tests/test_create_remove_wrapper.py
index 859568d..09ae0fc 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):
-- 
GitLab