示例#1
0
 def test_input_raises_value_error_if_wrong_len_of_data(self):
     self.input_data.pop(0)
     with self.assertRaises(ValueError) as e:
         Knapsack.process_input_data(self.input_data)
     self.assertTrue(
         Knapsack._DATA_LENGTH_ERROR.format(len(self.input_data))
         in str(e.exception))
示例#2
0
 def test_input_raises_value_error_if_wrong_input_type(self):
     self.input_data[1] = '3 4 5 A'
     with self.assertRaises(ValueError) as e:
         Knapsack.process_input_data(self.input_data)
     self.assertTrue('invalid literal' in str(e.exception))
示例#3
0
 def test_input_raises_value_error_if_wrong_input(self):
     self.input_data[2] = '3 4 5'
     with self.assertRaises(ValueError) as e:
         Knapsack.process_input_data(self.input_data)
     self.assertTrue(Knapsack._DATA_INPUT_ERROR in str(e.exception))
示例#4
0
 def test_input_processes_and_returns_list_succeeds(self):
     res = Knapsack.process_input_data(self.input_data)
     self.assertEqual(res, [7, [2, 3, 4, 5], [3, 4, 5, 5]])