Browse Source

tests: Look for tools in proper location without relying on PATH

rdb 2 years ago
parent
commit
4537540820
1 changed files with 17 additions and 6 deletions
  1. 17 6
      tests/test_tools.py

+ 17 - 6
tests/test_tools.py

@@ -1,19 +1,30 @@
 import pytest
 import subprocess
+import sys
+import os
 
 # Currently only works when Panda was installed from wheel
 panda3d_tools = pytest.importorskip("panda3d_tools")
 
+def get_tool(name):
+    if sys.platform == 'win32':
+        name += '.exe'
+
+    tools_dir = os.path.dirname(panda3d_tools.__file__)
+    path = os.path.join(tools_dir, name)
+    if not os.path.isfile(path):
+        pytest.skip(name + ' not found')
+
+    return path
+
 
[email protected](not hasattr(panda3d_tools, 'bam_info'),
-                    reason="requires bam-info")
 def test_bam_info():
-    output = subprocess.check_output(['bam-info', '-h'], stderr=subprocess.STDOUT).strip()
+    path = get_tool('bam-info')
+    output = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT).strip()
     assert output.startswith(b"This program scans one or more Bam files")
 
 
[email protected](not hasattr(panda3d_tools, 'pzip'),
-                    reason="requires pzip")
 def test_pzip():
-    output = subprocess.check_output(['pzip', '-h'], stderr=subprocess.STDOUT).strip()
+    path = get_tool('pzip')
+    output = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT).strip()
     assert output.startswith(b"This program compresses the named file")