Skip to content

Commit

Permalink
Use platform specific command to find path (#1143)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ThomasWilshaw authored and jminor committed Feb 11, 2022
1 parent 26915aa commit 3966b31
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import sys
import os
import subprocess
import sysconfig
import platform

try:
# python2
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3966b31

Please sign in to comment.