def test__format_display(self): # (npa, nxx, xxxx, ext, expect, label) tests = [ ('519', '291', '5554', '123', '(519) 291-5554 x123', 'all parts'), ('', '291', '5554', '123', '291-5554 x123', 'no npa'), ('519', '291', '5554', '', '(519) 291-5554', 'no ext'), ('', '291', '5554', '', '291-5554', '7 digits'), ('', '', '', '', '', 'no parts'), ] for t in tests: phone = PhoneNumber('') phone.npa = t[0] phone.nxx = t[1] phone.xxxx = t[2] phone.ext = t[3] self.assertEqual(phone.format_display(), t[4]) # Handle non-typical phone number value = 'Not Available' phone = PhoneNumber(value) self.assertEqual(phone.format_display(), value)