12 from traceback
import format_exc
14 FILENAME = f
"{__name__}.root"
19 import GaudiConfig2.Configurables.Gaudi.Tests.Histograms.CustomAxis
as T
26 algs.append(Alg(
"Alg"))
28 svcs.append(C.Gaudi.Histograming.Sink.Root(FileName=FILENAME))
29 svcs.append(C.Gaudi.Monitoring.MessageSvcSink())
35 yield C.ApplicationMgr(
43 if os.path.exists(FILENAME):
48 result[
"root_output_file"] = FILENAME
50 if not os.path.exists(FILENAME):
51 causes.append(
"missing histogram file")
56 f = ROOT.TFile.Open(FILENAME)
58 h = f.Get(
"Alg/Categories")
60 k = f.GetKey(
"Alg/Categories")
64 assert h,
"missing histogram"
66 if h.GetNbinsX() != 4:
67 causes.append(
"number of bins")
68 result[
"error"] = f
"expected 4 bins, got {h.GetNbinsX()}"
72 labels = list(axis.GetLabels())
73 expected = [
"Simple",
"Complex",
"Bad",
"Wrong"]
74 if labels != expected:
75 causes.append(
"wrong axis labels")
76 result[
"expected_labels"] =
", ".join(repr(l)
for l
in expected)
77 result[
"found_labels"] =
", ".join(repr(l)
for l
in labels)
80 except AssertionError
as err:
81 causes.append(str(err))
84 except Exception
as err:
85 causes.append(
"failure reading histogram file")
86 result[
"python_exception"] = result.Quote(format_exc())