def test_append_list_with_same_num_words(self): data1 = [1, "CustomPL", 3, 'a1', 'a2', 1] data2 = [1, "CustomPL", 3, 'b1', 'b2', 2] # check both data lists make valid NewMapListBlock individually mlb1 = NewMapListBlock(data1) self.assertEqual(1, len(mlb1)) mlb2 = NewMapListBlock(data2) self.assertEqual(1, len(mlb2)) # check both 2nd list can be appended to the 1st one. mlb3 = NewMapListBlock(data1) mlb3.append(data2) # check new list length self.assertEqual(len(mlb1) + len(mlb2), len(mlb3))
def test_append_list_with_different_num_words(self): data1 = [1, "CustomPL", 3, 'a1', 'a2', 1] data2 = [1, "CustomPL", 4, 'b1', 'b2', 1, 'b4'] # check both data lists make valid NewMapListBlock individually self.assertEqual(1, len(NewMapListBlock(data1))) self.assertEqual(1, len(NewMapListBlock(data2))) # check both 2nd list cannot be appended to the 1st one. mlb1 = NewMapListBlock(data1) self.assertEqual(3, mlb1._num_words) try: mlb1.append(data2) except MapListBlockError, err: self.assertIn('cannot append data', str(err), "expecting error message to contain 'cannot append data' but got %r instead" % err)
def test_append_list_with_different_num_words(self): data1 = [1, "CustomPL", 3, 'a1', 'a2', 1] data2 = [1, "CustomPL", 4, 'b1', 'b2', 1, 'b4'] # check both data lists make valid NewMapListBlock individually self.assertEqual(1, len(NewMapListBlock(data1))) self.assertEqual(1, len(NewMapListBlock(data2))) # check both 2nd list cannot be appended to the 1st one. mlb1 = NewMapListBlock(data1) self.assertEqual(3, mlb1._num_words) try: mlb1.append(data2) except MapListBlockError, err: self.assertIn( 'cannot append data', str(err), "expecting error message to contain 'cannot append data' but got %r instead" % err)