From f0166d650699f8efeade1ead996c9456ef96ea70 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Thu, 13 Feb 2025 15:38:00 +0100 Subject: [PATCH] test: Python test fixes: GSF + EDM4hep This fixes a few small issues with the GSF debugger (shebangs) and using the python interpreter that runs pytest (otherwise modules might not be available). It also forces DD4hep to write EDM4hep for the EDM4hep ddsim run, which gives a better error message if DD4hep was built without EDM4hep. --- Examples/Python/tests/test_misc.py | 4 ++-- Examples/Python/tests/test_reader.py | 1 + Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py | 2 +- Examples/Scripts/GsfDebugger/src/main.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/Python/tests/test_misc.py b/Examples/Python/tests/test_misc.py index 066fd4c999f..7a5d627106b 100644 --- a/Examples/Python/tests/test_misc.py +++ b/Examples/Python/tests/test_misc.py @@ -44,7 +44,7 @@ def test_gsf_debugger(tmp_path): env = os.environ.copy() env["PYTHONPATH"] = f"{scriptdir}:{env['PYTHONPATH']}" gsf_result = subprocess.run( - [gsf_script], capture_output=True, cwd=tmp_path, env=env + [sys.executable, gsf_script], capture_output=True, cwd=tmp_path, env=env ) logfile = tmp_path / "test.log" @@ -54,6 +54,6 @@ def test_gsf_debugger(tmp_path): assert gsf_result.returncode == 0 debugger_result = subprocess.run( - [debugger, f"--logfile={logfile}", "--nogui"], cwd=tmp_path + [sys.executable, debugger, f"--logfile={logfile}", "--nogui"], cwd=tmp_path ) assert debugger_result.returncode == 0 diff --git a/Examples/Python/tests/test_reader.py b/Examples/Python/tests/test_reader.py index 0153cc3b8d7..928ec8e5d35 100644 --- a/Examples/Python/tests/test_reader.py +++ b/Examples/Python/tests/test_reader.py @@ -278,6 +278,7 @@ def generate_input_test_edm4hep_simhit_reader(input, output): ddsim.gun.distribution = "eta" ddsim.numberOfEvents = 10 ddsim.outputFile = output + ddsim.outputConfig.forceEDM4HEP = True ddsim.run() diff --git a/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py b/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py index 7f4b466ee84..d19a2463fb8 100755 --- a/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py +++ b/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/usr/bin/env python3 from pathlib import Path diff --git a/Examples/Scripts/GsfDebugger/src/main.py b/Examples/Scripts/GsfDebugger/src/main.py index 81712c5e4d4..6acc7e55207 100755 --- a/Examples/Scripts/GsfDebugger/src/main.py +++ b/Examples/Scripts/GsfDebugger/src/main.py @@ -1,4 +1,4 @@ -#!/bin/env python3 +#!/usr/bin/env python3 import argparse import os import sys