From f1b6bee7f5ba0f2a52140b1be26dc53ef890bfc9 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 15 Sep 2023 20:18:54 +0200 Subject: [PATCH] Keep test_utils in podio module to make tests work --- python/podio/__init__.py | 8 ++++++++ tests/root_io/write_frame_root.py | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/python/podio/__init__.py b/python/podio/__init__.py index 477247fde..483885729 100644 --- a/python/podio/__init__.py +++ b/python/podio/__init__.py @@ -26,6 +26,14 @@ from . import EventStore + try: + # For some reason the test_utils only work at (test) runtime if they are + # imported with the rest of podio. Otherwise they produce a weird c++ error. + # This happens even if we import the *exact* same file. + from . import test_utils # noqa: F401 + except ImportError: + pass + # Make sure that this module is actually usable as podio even though most of # it is dynamically populated by cppyy sys.modules["podio"] = podio diff --git a/tests/root_io/write_frame_root.py b/tests/root_io/write_frame_root.py index 2609c602a..e0525a268 100644 --- a/tests/root_io/write_frame_root.py +++ b/tests/root_io/write_frame_root.py @@ -1,12 +1,7 @@ #!/usr/bin/env python3 """Script to write a Frame in ROOT format""" -import os -import sys - -sys.path.append(os.path.join(os.environ.get("PODIO_BASE"), "python", "podio")) - -import test_utils # pylint: disable=import-error, disable=wrong-import-position +from podio import test_utils from podio.root_io import Writer # pylint: disable=wrong-import-position