From 76ae71f5ca6f1a68a6fdd2ff38dab4511b1aa193 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Tue, 17 Sep 2024 13:13:03 +0200 Subject: [PATCH] Skip the full file check if the rntuple file has not been produced (#369) --- test/CMakeLists.txt | 1 + test/conftest.py | 10 ++++++++++ test/test_EDM4hepFile.py | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b239e31bf..b45e8f03e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,6 +35,7 @@ set_tests_properties( check_complete_file_rntuple PROPERTIES DEPENDS create_complete_file_rntuple + SKIP_REGULAR_EXPRESSION "collected 0 items / 1 skipped" ) set_tests_properties( diff --git a/test/conftest.py b/test/conftest.py index eacd06cd0..228cc9be1 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,8 +1,18 @@ #!/usr/bin/env python3 """pytest config module to make passing of input file name possible""" +"""The pytest options after configuration""" +options = None + def pytest_addoption(parser): """Hook to add an inputfile argument to pytest for checking EDM4hep file contents""" parser.addoption("--inputfile", action="store") + + +def pytest_configure(config): + """This is a slighty hacky solution to make the pytest configuration + available in test modules outside of fixtures""" + global options + options = config.option diff --git a/test/test_EDM4hepFile.py b/test/test_EDM4hepFile.py index 51f0445ad..b23a569b4 100644 --- a/test/test_EDM4hepFile.py +++ b/test/test_EDM4hepFile.py @@ -3,16 +3,26 @@ created by scripts/createEDM4hepFile.py has the expected contents """ +import os import podio import edm4hep import pytest from itertools import count +from conftest import options + # For now simply copy these from createEDM4hepFile.py FRAMES = 3 VECTORSIZE = 5 COUNT_START = 42 # Starting point for the counters +# Skip the test if an rntuple file has not been produced +if "rntuple" in options.inputfile and not os.path.isfile(options.inputfile): + pytest.skip( + "Skipping rntuple reading tests, because input is not produced", + allow_module_level=True, + ) + @pytest.fixture(scope="module") def inputfile_name(pytestconfig):