Esempio n. 1
0
 def test_05_append(self):
   for chk in ({}, dict(a=1), 'Paper1'):
     with self.subTest(chk=chk):
       pl = PaperList(None)
       with self.assertRaises(ValueError) as e:
         pl.append(chk)
       self.assertEqual(e.exception.args[0], "All elements must be 'PaperInfo' instances")    
Esempio n. 2
0
 def test_13_getitem(self):
   pl = PaperList([pi1, pi3])
   self.assertEqual(pl['Paper1'], pi1)
Esempio n. 3
0
 def test_12_getitem(self):
   pl = PaperList([pi1, pi3])
   with self.assertRaises(ValueError) as e:
     pl[pi2]
   self.assertEqual(e.exception.args[0], "Must pass an integer or string to use as index")
Esempio n. 4
0
 def test_11_getitem(self):
   pl = PaperList([pi1, pi3])
   with self.assertRaises(ValueError) as e:
     pl['Name3']
   self.assertEqual(e.exception.args[0], "Unable to find item indexed by 'Name3'")
Esempio n. 5
0
 def test_10_getitem(self):
   pl = PaperList([pi1, pi3])
   self.assertEqual(pl[1], pi3)
Esempio n. 6
0
 def test_09_extend(self):
   pl = PaperList(None)
   pl.extend(pi1, [pi2, pi3])
   self.assertListEqual(pl, [pi1, pi2, pi3])
Esempio n. 7
0
 def test_07_append(self):
   pl = PaperList(None)
   with self.assertRaises(TypeError) as e:
     pl.append(pi1, pi2, pi3)
   self.assertEqual(e.exception.args[0], "append() takes 2 positional arguments but 4 were given")
Esempio n. 8
0
 def test_06_append(self):
   pl = PaperList(None)
   pl.append(pi1)
   self.assertListEqual(pl, [pi1])
Esempio n. 9
0
 def test_03_init(self):
   for chk in ([], ()):
     with self.subTest(chk=chk):
       with self.assertRaises(ValueError) as e:
         pl = PaperList(chk)
       self.assertEqual(e.exception.args[0], "Must provide a sequence with at least one 'PaperInfo' instance")
Esempio n. 10
0
 def test_02_init(self):
   'Initialise an empty list'
   pl = PaperList(None)
   self.assertListEqual(pl, [])
Esempio n. 11
0
 def test_01_init(self):
   'Initialise no arguments'
   pl = PaperList()
   self.assertListEqual(pl, [])