def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self.particle_type = geant2pdg(int(self.args[0])) try: self.length = self.args[1] except IndexError: self.length = 0
def test_geant2pdg_returns_0_for_unknown_particle_id(self): self.assertEqual(0, geant2pdg(-999))
def test_geant2pdg(self): self.assertEqual(22, geant2pdg(1)) self.assertEqual(-13, geant2pdg(5))