def test_valid_when_11_digits_and_first_is_1_with_punctuation(self): number = Phone("+1 (223) 456-7890").number self.assertEqual(number, "2234567890")
def test_pretty_print(self): number = Phone("1234567890") self.assertEqual(number.pretty(), "(123) 456-7890")
def test_cleans_number_with_multiple_spaces(self): number = Phone("223 456 7890 ").number self.assertEqual(number, "2234567890")
def test_invalid_when_11_digits_and_first_not_1(self): with self.assertRaisesWithMessage(ValueError): Phone("22234567890")
def test_area_code(self): number = Phone("2234567890") self.assertEqual(number.area_code, "223")
def test_pretty_print_with_full_us_phone_number(self): number = Phone("12234567890") self.assertEqual(number.pretty(), "(223) 456-7890")
def test_area_code(self): number = Phone("1234567890") self.assertEqual("123", number.area_code())
def test_cleans_number(self): number = Phone("(223) 456-7890").number self.assertEqual(number, "2234567890")
def test_invalid_exchange_code(self): number = Phone("(223) 056-7890").number self.assertEqual(number, "0000000000")
def test_invalid_when_9_digits(self): number = Phone("123456789").number self.assertEqual("0000000000", number)
def test_invalid_area_code(self): number = Phone("(123) 456-7890").number self.assertEqual(number, "0000000000")
def test_invalid_with_punctuation(self): number = Phone("123-@:!-7890").number self.assertEqual(number, "0000000000")
def test_invalid_with_letters(self): number = Phone("123-abc-7890").number self.assertEqual(number, "0000000000")
def test_invalid_when_more_than_11_digits(self): number = Phone("321234567890").number self.assertEqual(number, "0000000000")
def test_pretty_print(self): number = Phone("1234567890") self.assertEqual("(123) 456-7890", number.pretty())
def test_invalid_if_area_code_starts_with_1_on_valid_11_digit_number(self): with self.assertRaisesWithMessage(ValueError): Phone("1 (123) 456-7890")
def test_cleans_number(self): number = Phone("(123) 456-7890").number self.assertEqual("1234567890", number)
def test_invalid_exchange_code_starts_with_1_valid_11_digit_number(self): with self.assertRaisesWithMessage(ValueError): Phone("1 (223) 156-7890")
from phone_number import Phone number = Phone("12234567890") print(number.area_code)
def test_pretty_print(self): number = Phone("2234567890") self.assertEqual(number.pretty(), "(223) 456-7890")
def test_invalid_when_more_than_11_digits(self): with self.assertRaisesWithMessage(ValueError): Phone("321234567890")
def test_cleans_number_with_dots(self): number = Phone("223.456.7890").number self.assertEqual(number, "2234567890")
def test_invalid_with_letters(self): with self.assertRaisesWithMessage(ValueError): Phone("123-abc-7890")
def test_invalid_when_9_digits(self): with self.assertRaisesWithMessage(ValueError): Phone("123456789")
def test_invalid_with_punctuation(self): with self.assertRaisesWithMessage(ValueError): Phone("123-@:!-7890")
def test_valid_when_11_digits_and_first_is_1(self): number = Phone("12234567890").number self.assertEqual(number, "2234567890")
def test_invalid_if_area_code_starts_with_1(self): with self.assertRaisesWithMessage(ValueError): Phone("(123) 456-7890")
def test_area_code(self): number = Phone("1234567890") self.assertEqual(number.area_code(), "123")
def test_invalid_if_exchange_code_starts_with_1(self): with self.assertRaisesWithMessage(ValueError): Phone("(223) 156-7890")
def test_pretty_print_with_full_us_phone_number(self): number = Phone("11234567890") self.assertEqual(number.pretty(), "(123) 456-7890")
def test_invalid_when_11_digits_and_first_not_1(self): number = Phone("22234567890").number self.assertEqual(number, "0000000000")