def test_config(self): ana1 = cfg.Analyzer(Analyzer, toto='1', tata='a') comp1 = cfg.Component('comp1', files='*.root', triggers='HLT_stuff') from heppy.framework.chain import Chain as Events config = cfg.Config(components=[comp1], sequence=[ana1], services=[], events_class=Events)
def test_copy(self): ana1 = cfg.Analyzer( Analyzer, instance_label='inst1', toto='1', ) ana2 = copy.copy(ana1) ana2.instance_label = 'inst2' ana2.toto2 = '2' self.assertTrue(ana2.name.endswith('analyzer.Analyzer_inst2')) self.assertEqual(ana2.toto2, '2')
def test_pickle(self): '''Test that a config object can be pickled and unpickled''' import pickle import shelve import tempfile ana = cfg.Analyzer( Analyzer, 'test_pickle', var=1, fun=lambda x: x # works because dill is imported in config.py ) fd, tmpfname = tempfile.mkstemp() os.close(fd) with open(tmpfname, 'w') as out: pickle.dump(ana, out) self.assertTrue(True) with open(tmpfname) as infile: ana2 = pickle.load(infile) self.assertEqual(ana2.fun(1), 1)
def test_analyzer(self): ana1 = cfg.Analyzer(Analyzer, toto='1', tata='a') # checking that the analyzer name does not contain a slash, # to make sure the output directory name does not contain a subdirectory self.assertTrue('/' not in ana1.name)