Sha256: 4f8842167c0275d26d967623fa3ee4d30bec9af01ed84957d02c67f65715902c
Contents?: true
Size: 1.2 KB
Versions: 101
Compression:
Stored size: 1.2 KB
Contents
import unittest from phone_number import Phone class PhoneTest(unittest.TestCase): def test_cleans_number(self): number = Phone("(123) 456-7890").number self.assertEqual("1234567890", number) def test_cleans_number_with_dots(self): number = Phone("123.456.7890").number self.assertEqual("1234567890", number) def test_valid_when_11_digits_and_first_is_1(self): number = Phone("11234567890").number self.assertEqual("1234567890", number) def test_invalid_when_11_digits(self): number = Phone("21234567890").number self.assertEqual("0000000000", number) def test_invalid_when_9_digits(self): number = Phone("123456789").number self.assertEqual("0000000000", number) def test_area_code(self): number = Phone("1234567890") self.assertEqual("123", number.area_code()) def test_pretty_print(self): number = Phone("1234567890") self.assertEqual("(123) 456-7890", number.pretty()) def test_pretty_print_with_full_us_phone_number(self): number = Phone("11234567890") self.assertEqual("(123) 456-7890", number.pretty()) if __name__ == '__main__': unittest.main()
Version data entries
101 entries across 101 versions & 1 rubygems
Version | Path |
---|---|
trackler-2.0.3.1 | tracks/python/exercises/phone-number/phone_number_test.py |