From f12357e2622d9339220ca15c8cf73f79d8004f9a Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Sat, 13 Nov 2021 01:15:22 +0000 Subject: [PATCH 1/5] Use platform specific command to find path --- tests/test_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_console.py b/tests/test_console.py index d192717ae..7c76edc37 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -84,7 +84,7 @@ def run_test(self): try: subprocess.check_call( [ - "which", sys.argv[0] + "where" if os.name == "nt" else "which", sys.argv[0] ], stdout=subprocess.PIPE ) From ceeaf02e7dccc8c07e63650b9af893f0a78d4b2d Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Wed, 17 Nov 2021 14:50:11 +0000 Subject: [PATCH 2/5] Remove usage of which as it is being deprecated --- tests/test_console.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/test_console.py b/tests/test_console.py index 7c76edc37..075fd5a17 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -28,6 +28,8 @@ import sys import os import subprocess +import sysconfig +import fnmatch try: # python2 @@ -81,19 +83,16 @@ def setUp(self): def run_test(self): if self.SHELL_OUT: # make sure its on the path - try: - subprocess.check_call( - [ - "where" if os.name == "nt" else "which", sys.argv[0] - ], - stdout=subprocess.PIPE - ) - except subprocess.CalledProcessError: - self.fail( - "Could not find '{}' on $PATH. Tests that explicitly shell" + + console_script = os.path.join(sysconfig.get_path('scripts'), sys.argv[0]) + if not os.path.exists(console_script): + # We might be on Windows + if not os.path.exists(console_script + ".exe"): + self.fail( + "Could not find '{}'. Tests that explicitly shell" " out can be disabled by setting the environment variable " - "OTIO_DISABLE_SHELLOUT_TESTS.".format(sys.argv[0]) - ) + "OTIO_DISABLE_SHELLOUT_TESTS.".format(console_script) + ) # actually run the test (sys.argv is already populated correctly) proc = subprocess.Popen( From 5b463e3c0cffa8697abbe940930ce5d8f4f0d2fc Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Fri, 10 Dec 2021 23:23:44 +0000 Subject: [PATCH 3/5] Update based on PR comments. --- tests/test_console.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_console.py b/tests/test_console.py index 075fd5a17..2fb1a2ef5 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -30,6 +30,7 @@ import subprocess import sysconfig import fnmatch +import platform try: # python2 @@ -85,14 +86,15 @@ def run_test(self): # make sure its on the path console_script = os.path.join(sysconfig.get_path('scripts'), sys.argv[0]) + if platform.system() == 'Windows': + console_script += '.exe' + if not os.path.exists(console_script): - # We might be on Windows - if not os.path.exists(console_script + ".exe"): - self.fail( + self.fail( "Could not find '{}'. Tests that explicitly shell" " out can be disabled by setting the environment variable " "OTIO_DISABLE_SHELLOUT_TESTS.".format(console_script) - ) + ) # actually run the test (sys.argv is already populated correctly) proc = subprocess.Popen( From 8191c81510a9ac5920c5ea798e5b2000fcc48fe1 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Fri, 10 Dec 2021 23:29:12 +0000 Subject: [PATCH 4/5] Cleanup --- tests/test_console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_console.py b/tests/test_console.py index 2fb1a2ef5..04767d9e7 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -29,7 +29,6 @@ import os import subprocess import sysconfig -import fnmatch import platform try: From 83985aaf9a62b40fac222274fc790a4b1f3d40be Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Fri, 10 Dec 2021 23:32:10 +0000 Subject: [PATCH 5/5] Remove blank line --- tests/test_console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_console.py b/tests/test_console.py index 04767d9e7..3fd860158 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -83,7 +83,6 @@ def setUp(self): def run_test(self): if self.SHELL_OUT: # make sure its on the path - console_script = os.path.join(sysconfig.get_path('scripts'), sys.argv[0]) if platform.system() == 'Windows': console_script += '.exe'