ATLAS Offline Software
Loading...
Searching...
No Matches
DataQuality/DQUtils/python/tests.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3from pickle import dump, loads
4from functools import wraps
5from os import environ
6from pkg_resources import resource_string
7
8def invariant(test_data_name):
9 def wrapper(func):
10 testfile = "%s.%s" % (func.__name__, test_data_name)
11 @wraps(func)
12 def check_invariant(*args, **kwargs):
13 result = func(*args, **kwargs)
14 if "DQU_UPDATE_TEST_DATA" in environ:
15 with open(test_data_name, "wb") as fd:
16 dump(result, fd)
17 print("Wrote updated test data")
18 else:
19 test_data = loads(resource_string("testdata", testfile))
20 assert result == test_data, "Data considered 'invariant' has changed"
21 return check_invariant
22
23 return wrapper
void print(char *figname, TCanvas *c1)
-event-from-file