12 from traceback
import format_exc
14 FILENAME = f
"{__name__}.root"
15 FILENAMEJSON = f
"{__name__}.json"
20 import GaudiConfig2.Configurables.Gaudi.Tests.Histograms.CustomAxis
as T
27 algs.append(Alg(
"Alg"))
29 svcs.append(C.Gaudi.Histograming.Sink.Root(FileName=FILENAME))
30 svcs.append(C.Gaudi.Monitoring.JSONSink(FileName=FILENAMEJSON))
31 svcs.append(C.Gaudi.Monitoring.MessageSvcSink())
37 yield C.ApplicationMgr(
45 if os.path.exists(FILENAME):
50 result[
"root_output_file"] = FILENAME
52 if not os.path.exists(FILENAME):
53 causes.append(
"missing histogram file")
59 f = ROOT.TFile.Open(FILENAME)
61 h = f.Get(
"Alg/Categories")
63 k = f.GetKey(
"Alg/Categories")
67 assert h,
"missing histogram"
69 if h.GetNbinsX() != 4:
70 causes.append(
"number of bins")
71 result[
"error"] = f
"expected 4 bins, got {h.GetNbinsX()}"
75 labels = list(axis.GetLabels())
76 expected = [
"Simple",
"Complex",
"Bad",
"Wrong"]
77 if labels != expected:
78 causes.append(
"wrong axis labels")
79 result[
"expected_labels"] =
", ".join(repr(l)
for l
in expected)
80 result[
"found_labels"] =
", ".join(repr(l)
for l
in labels)
83 except AssertionError
as err:
84 causes.append(str(err))
88 causes.append(
"failure reading histogram file")
89 result[
"python_exception"] = result.Quote(format_exc())