From: Michael Fladischer Date: Sun, 1 Apr 2018 10:52:56 +0200 Subject: Fix tests to work with local XML data from iso-codes package. --- django_countries/tests/test_countries.py | 6 ++++-- django_countries/tests/test_fields.py | 13 ++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/django_countries/tests/test_countries.py b/django_countries/tests/test_countries.py index 612ad3d..2f12eb4 100644 --- a/django_countries/tests/test_countries.py +++ b/django_countries/tests/test_countries.py @@ -209,8 +209,10 @@ class TestCountriesObject(BaseTest): @pytest.mark.skipif(not settings.USE_I18N, reason="No i18n") def test_fetch_by_name_i18n(self): - code = countries.by_name("Estados Unidos", language="es") - self.assertEqual(code, "US") + #code = countries.by_name("Estados Unidos", language="es") + #self.assertEqual(code, "US") + code = countries.by_name('Finlandia', language='es') + self.assertEqual(code, 'FI') def test_fetch_by_name_no_match(self): self.assertEqual(countries.by_name("Neverland"), "") diff --git a/django_countries/tests/test_fields.py b/django_countries/tests/test_fields.py index 33d5651..e2599f7 100644 --- a/django_countries/tests/test_fields.py +++ b/django_countries/tests/test_fields.py @@ -269,19 +269,14 @@ class TestCountryField(TestCase): def test_by_country_name_endswith(self): p = Person.objects.create(name="A", country="AS") # American Samoa - pp = Person.objects.create(name="A", country="US") # United States of America self.assertEqual( - set(Person.objects.filter(country__contains="America")), {p, pp} + set(Person.objects.filter(country__contains="America")), {p} ) - self.assertEqual(list(Person.objects.filter(country__endswith="America")), [pp]) self.assertEqual(list(Person.objects.filter(country__endswith="america")), []) - self.assertEqual( - list(Person.objects.filter(country__iendswith="america")), [pp] - ) # Also works with country codes. - self.assertEqual(list(Person.objects.filter(country__endswith="US")), [pp]) - self.assertEqual(list(Person.objects.filter(country__endswith="us")), []) - self.assertEqual(list(Person.objects.filter(country__iendswith="us")), [pp]) + self.assertEqual(list(Person.objects.filter(country__endswith="AS")), [p]) + self.assertEqual(list(Person.objects.filter(country__endswith="as")), []) + self.assertEqual(list(Person.objects.filter(country__iendswith="as")), [p]) def test_by_country_name_regex(self): p = Person.objects.create(name="A", country="MK") # North Macedonia