def parameterized_test_with_exception(self, exception, input_data): try: operation(input_data) self.fail() except exception: pass
def parameterized_test(self, expected, input_data): actual = operation(input_data) self.assertEqual(expected, actual)
def test_invalid_data_too_large_ascii_value(self): with self.assertRaises(ValidationError): operation('2')
def test_invalid_data_too_long2(self): with self.assertRaises(ValidationError): operation('111111111')
def test_invalid_data_too_short(self): with self.assertRaises(ValidationError): operation('')
def test_valid_data(self): self.assertEqual(0b0, operation('0')) self.assertEqual(0b1, operation('1')) self.assertEqual(0b0, operation('00000000')) self.assertEqual(0b11111111, operation('11111111'))