Exemple #1
0
 def test_negative_length_raises_type_error(self):
     """should raise a TypeError if length is negative."""
     with self.assertRaises(TypeError):
         luhn.generate(-1)
Exemple #2
0
 def test_length_too_short_raises_type_error(self):
     """should raise a TypeError if length is too short."""
     with self.assertRaises(TypeError):
         luhn.generate(1)
Exemple #3
0
 def test_length_as_float_raises_type_error(self):
     """should raise a TypeError if length is a float."""
     with self.assertRaises(TypeError):
         luhn.generate(2.1)
Exemple #4
0
 def test_zero_length_raises_type_error(self):
     """should raise a TypeError if length is 0."""
     with self.assertRaises(TypeError):
         luhn.generate(0)
Exemple #5
0
 def test_generates_valid_number_of_specified_length(self):
     """should generate a valid number of specified length."""
     number = luhn.generate(5)
     self.assertEqual(len(number), 5)
     self.assertTrue(luhn.is_valid(number))