@@ -201,13 +201,6 @@ def testIsNumberGeographical(self):
201201 self .assertTrue (phonenumberutil .is_number_geographical (MX_MOBILE1 )) # Mexico, mobile phone number.
202202 self .assertTrue (phonenumberutil .is_number_geographical (MX_MOBILE2 )) # Mexico, another mobile phone number.
203203
204- def testIsLeadingZeroPossible (self ):
205- self .assertTrue (phonenumberutil ._is_leading_zero_possible (39 )) # Italy
206- self .assertFalse (phonenumberutil ._is_leading_zero_possible (1 )) # USA
207- self .assertTrue (phonenumberutil ._is_leading_zero_possible (800 )) # International toll free
208- self .assertFalse (phonenumberutil ._is_leading_zero_possible (979 )) # International premium-rate
209- self .assertFalse (phonenumberutil ._is_leading_zero_possible (888 )) # Not in metadata file, just default to False
210-
211204 def testGetLengthOfGeographicalAreaCode (self ):
212205 # Google MTV, which has area code "650".
213206 self .assertEqual (3 , phonenumbers .length_of_geographical_area_code (US_NUMBER ))
@@ -712,7 +705,7 @@ def testFormatWithPreferredCarrierCode(self):
712705 str (arNumber ))
713706 self .assertEqual ("PhoneNumber(country_code=54, national_number=91234125678, extension=None, "
714707 "italian_leading_zero=None, number_of_leading_zeros=None, "
715- "country_code_source=None , preferred_domestic_carrier_code='19')" ,
708+ "country_code_source=0 , preferred_domestic_carrier_code='19')" ,
716709 repr (arNumber ))
717710 # When the preferred_domestic_carrier_code is present (even when it is
718711 # just a space), use it instead of the default carrier code passed in.
@@ -1896,8 +1889,7 @@ def testMaybeExtractCountryCode(self):
18961889 ccc , numberToFill = phonenumberutil ._maybe_extract_country_code (phoneNumber , metadata , False , number )
18971890 self .assertEqual (countryCallingCode , ccc ,
18981891 msg = "Should have extracted the country calling code of the region passed in" )
1899- self .assertFalse (number .country_code_source is not None ,
1900- msg = "Should not contain CountryCodeSource." )
1892+ self .assertEqual (CountryCodeSource .UNSPECIFIED , number .country_code_source )
19011893 except NumberParseException :
19021894 e = sys .exc_info ()[1 ]
19031895 self .fail ("Should not have thrown an exception: %s" % e )
@@ -1909,8 +1901,7 @@ def testMaybeExtractCountryCode(self):
19091901 self .assertEqual (0 , ccc ,
19101902 msg = ("Should not have extracted a country calling code - invalid number after " +
19111903 "extraction of uncertain country calling code." ))
1912- self .assertFalse (number .country_code_source is not None ,
1913- msg = "Should not contain CountryCodeSource." )
1904+ self .assertEqual (CountryCodeSource .UNSPECIFIED , number .country_code_source )
19141905 except NumberParseException :
19151906 e = sys .exc_info ()[1 ]
19161907 self .fail ("Should not have thrown an exception: %s" % e )
@@ -1931,6 +1922,9 @@ def testMaybeExtractCountryCode(self):
19311922 def testParseNationalNumber (self ):
19321923 # National prefix attached.
19331924 self .assertEqual (NZ_NUMBER , phonenumbers .parse ("033316005" , "NZ" ))
1925+ # Some fields are not filled in by parse when keep_raw_input is not set.
1926+ self .assertEqual (CountryCodeSource .UNSPECIFIED , NZ_NUMBER .country_code_source )
1927+
19341928 self .assertEqual (NZ_NUMBER , phonenumbers .parse ("33316005" , "NZ" ))
19351929 # National prefix attached and some formatting present.
19361930 self .assertEqual (NZ_NUMBER , phonenumbers .parse ("03-331 6005" , "NZ" ))
0 commit comments