class ReprTest(TestCase): """PCSet and PSet repr's vary based on ordered and multiset settings""" def setUp(self): self.l = [0, 1, -7, 16, 1, 0] self.pcset = PCSet(self.l) self.pset = PSet(self.l) def testreprO(self): self.pcset.ordered(True) self.pset.ordered(True) self.pcset.multiset(False) self.pset.multiset(False) self.assertEqual(self.pcset.__repr__(), '[0, 1, 5, 4]') self.assertEqual(self.pset.__repr__(), '[0, 1, -7, 16]') def testreprO_Multi(self): pcset = PCSet(self.l, ordered=True, multiset=True) pset = PSet(self.l, ordered=True, multiset=True) self.assertEqual(pcset.__repr__(), '[0, 1, 5, 4, 1, 0]') self.assertEqual(pset.__repr__(), '[0, 1, -7, 16, 1, 0]') def testreprUO(self): self.pcset.ordered(False) self.pset.ordered(False) self.pcset.multiset(False) self.pset.multiset(False) self.assertEqual(self.pcset.__repr__(), '[0, 1, 4, 5]') self.assertEqual(self.pset.__repr__(), '[-7, 0, 1, 16]') def testreprUO_Multi(self): pcset = PCSet(self.l, ordered=False, multiset=True) pset = PSet(self.l, ordered=False, multiset=True) self.assertEqual(pcset.__repr__(), '[0, 0, 1, 1, 4, 5]') self.assertEqual(pset.__repr__(), '[-7, 0, 0, 1, 1, 16]')
def testreprUO_Multi(self): pcset = PCSet(self.l, ordered=False, multiset=True) pset = PSet(self.l, ordered=False, multiset=True) self.assertEqual(pcset.__repr__(), '[0, 0, 1, 1, 4, 5]') self.assertEqual(pset.__repr__(), '[-7, 0, 0, 1, 1, 16]')
def testreprO_Multi(self): pcset = PCSet(self.l, ordered=True, multiset=True) pset = PSet(self.l, ordered=True, multiset=True) self.assertEqual(pcset.__repr__(), '[0, 1, 5, 4, 1, 0]') self.assertEqual(pset.__repr__(), '[0, 1, -7, 16, 1, 0]')