From 3966b3184350c417958bf2bbf9e589539c30c78e Mon Sep 17 00:00:00 2001 From: ThomasWilshaw Date: Fri, 10 Dec 2021 23:32:54 +0000 Subject: [PATCH] Use platform specific command to find path (#1143) * Use platform specific command to find path * Remove usage of which as it is being deprecated * Update based on PR comments. * Cleanup * Remove blank line --- tests/test_console.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/test_console.py b/tests/test_console.py index d192717ae6..3fd8601589 100755 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -28,6 +28,8 @@ import sys import os import subprocess +import sysconfig +import platform try: # python2 @@ -81,18 +83,15 @@ def setUp(self): def run_test(self): if self.SHELL_OUT: # make sure its on the path - try: - subprocess.check_call( - [ - "which", sys.argv[0] - ], - stdout=subprocess.PIPE - ) - except subprocess.CalledProcessError: + 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): self.fail( - "Could not find '{}' on $PATH. Tests that explicitly shell" + "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)