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")
57 f = ROOT.TFile.Open(FILENAME)
59 h = f.Get(
"Alg/Categories")
61 k = f.GetKey(
"Alg/Categories")
65 assert h,
"missing histogram"
67 if h.GetNbinsX() != 4:
68 causes.append(
"number of bins")
69 result[
"error"] = f
"expected 4 bins, got {h.GetNbinsX()}"
73 labels = list(axis.GetLabels())
74 expected = [
"Simple",
"Complex",
"Bad",
"Wrong"]
75 if labels != expected:
76 causes.append(
"wrong axis labels")
77 result[
"expected_labels"] =
", ".join(repr(l)
for l
in expected)
78 result[
"found_labels"] =
", ".join(repr(l)
for l
in labels)
81 except AssertionError
as err:
82 causes.append(str(err))
85 except Exception
as err:
86 causes.append(
"failure reading histogram file")
87 result[
"python_exception"] = result.Quote(format_exc())