def test_get_country_name_from_iso2(self): assert Country.get_country_name_from_iso2('jp') == 'Japan' assert Country.get_country_name_from_iso2('ab') is None assert Country.get_country_name_from_iso2('Pl') == 'Poland' assert Country.get_country_name_from_iso2('SG') == 'Singapore' assert Country.get_country_name_from_iso2('SGP') is None with pytest.raises(LocationError): Country.get_country_name_from_iso2('SGP', exception=LocationError) assert Country.get_country_name_from_iso2('VE') == 'Venezuela (Bolivarian Republic of)' assert Country.get_country_name_from_iso2('TW') == 'Taiwan (Province of China)' assert Country.get_country_name_from_iso2('PS') == 'oPt'
def get_country_region_name(cls, code): countryname = Country.get_country_name_from_iso2(code, shortname=True) if countryname: return countryname regionname = cls.region_code_to_name.get(code) if regionname: return f"{regionname} (no country specified)" return cls.default_country_region