File indexing completed on 2025-01-30 09:17:42
0001
0002 """
0003 Some imports to make sure that the DD4hep environment is complete.
0004 Since it can be disabled in CMake, the import of DDG4 is tested in another file.
0005 """
0006 from __future__ import absolute_import, unicode_literals, print_function
0007 import traceback
0008 import warnings
0009 import pytest
0010
0011 parametrize = pytest.mark.parametrize
0012
0013 ImportFehler = ImportError
0014 FEHLER = "ERROR: "
0015
0016 moduleNames = [
0017 'dd4hep',
0018 'DDRec',
0019 'dddigi',
0020 ]
0021
0022
0023
0024 ALLOWED_TO_FAIL = []
0025
0026
0027
0028 GRAPHIC_MODULES = []
0029
0030
0031 @parametrize('moduleName', moduleNames)
0032 def test_module(moduleName):
0033 """ Try to import a module from DD4hep.
0034
0035 Modules that are in the ALLOWED_TO_FAIL list are shown as skipped and generate a warning
0036
0037 Modules that require graphic libraries (GRAPHIC_MODULES) are skipped on container
0038 """
0039
0040 try:
0041 __import__(moduleName)
0042
0043
0044
0045 except ImportFehler as e:
0046 msg = "could not import %s: %s" % (moduleName, repr(e))
0047 print(traceback.print_exc())
0048
0049 if moduleName in ALLOWED_TO_FAIL:
0050 warnings.warn(msg, stacklevel=2)
0051 pytest.skip("WARN: " + msg)
0052 elif moduleName in GRAPHIC_MODULES:
0053 warnings.warn(msg + "(Possibly due to system graphic libraries not present)", stacklevel=2)
0054 pytest.skip("WARN: " + msg + "(Possibly due to system graphic libraries not present)")
0055 else:
0056 pytest.fail(FEHLER + msg)