def raise_not_enough_arguments(self, string): """ Raises an errors.ArgumentError if not enough arguments were supplied. Takes care of formatting for detailed error messages. Arguments: string (str): The string of the phrase for which there weren't enough arguments. Raises: errors.ArgumentError with a detailed error message. """ requested = errors.number(self.counter + 1) number = len(self.positional) verb = "was" if number == 1 else "were" what = "Requested {} formatting argument for "\ "'{}' but only {} {} supplied!" what = what.format(requested, string, number, verb) raise errors.ArgumentError(what)
def test_spoken_word_number_retrieval(self): self.assertEqual(errors.number(0), "a 0th") self.assertEqual(errors.number(1), "a 1st") self.assertEqual(errors.number(2), "a 2nd") self.assertEqual(errors.number(3), "a 3rd") self.assertEqual(errors.number(5), "a 5th") self.assertEqual(errors.number(8), "an 8th") self.assertEqual(errors.number(11), "an 11th") self.assertEqual(errors.number(21), "a 21st") self.assertEqual(errors.number(32), "a 32nd") self.assertEqual(errors.number(56), "a 56th") self.assertEqual(errors.number(123), "a 123rd") self.assertEqual(errors.number(11000), "an 11,000th") self.assertEqual(errors.number(8000000), "an 8,000,000th")