Skip to content

Commit 3fe08a7

Browse files
committed
Merge code changes from upstream r579
1 parent a487fa1 commit 3fe08a7

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

python/phonenumbers/phonenumberutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ def _formatting_rule_has_first_group_only(national_prefix_formatting_rule):
684684
"""Helper function to check if the national prefix formatting rule has the
685685
first group only, i.e., does not start with the national prefix.
686686
"""
687-
if national_prefix_formatting_rule is None: # pragma no cover
688-
return False
687+
if national_prefix_formatting_rule is None:
688+
return True
689689
return bool(fullmatch(_FIRST_GROUP_ONLY_PREFIX_PATTERN,
690690
national_prefix_formatting_rule))
691691

python/tests/asyoutypetest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,15 @@ def testAYTFLongNDD_SG(self):
906906
self.assertEqual("777777 9876 789", formatter.input_digit('9'))
907907
self.assertEqual("777777 9876 7890", formatter.input_digit('0'))
908908

909+
def testAYTFNoNationalPrefixFormattingRule(self):
910+
formatter = AsYouTypeFormatter("AO")
911+
self.assertEqual("3", formatter.input_digit('3'));
912+
self.assertEqual("33", formatter.input_digit('3'));
913+
self.assertEqual("333", formatter.input_digit('3'));
914+
self.assertEqual("333 3", formatter.input_digit('3'));
915+
self.assertEqual("333 33", formatter.input_digit('3'));
916+
self.assertEqual("333 333", formatter.input_digit('3'));
917+
909918
def testAYTFShortNumberFormattingFix_AU(self):
910919
# For Australia, the national prefix is not optional when formatting.
911920
formatter = AsYouTypeFormatter("AU")

0 commit comments

Comments
 (0)