pycountry: FTBFS: dh_auto_test: error: pybuild --test -i python{version} -p 3.9 returned exit code 13

Bug #1953072 reported by Brian Murray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pycountry (Debian)
Fix Released
Unknown
pycountry (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Imported from Debian bug http://bugs.debian.org/998565:

Source: pycountry
Version: 20.7.3+ds1-1
Severity: serious
Justification: FTBFS
Tags: bookworm sid ftbfs
User: <email address hidden>
Usertags: ftbfs-20211104 ftbfs-bookworm

Hi,

During a rebuild of all packages in sid, your package failed to build
on amd64.

Relevant part (hopefully):
> debian/rules binary
> dh binary --with python3 --buildsystem=pybuild
> dh_update_autotools_config -O--buildsystem=pybuild
> dh_autoreconf -O--buildsystem=pybuild
> dh_auto_configure -O--buildsystem=pybuild
> I: pybuild base:232: python3.9 setup.py config
> running config
> dh_auto_build -O--buildsystem=pybuild
> I: pybuild base:232: /usr/bin/python3 setup.py build
> running build
> running build_py
> creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build/pycountry
> copying src/pycountry/__init__.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build/pycountry
> copying src/pycountry/db.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build/pycountry
> running egg_info
> creating src/pycountry.egg-info
> writing src/pycountry.egg-info/PKG-INFO
> writing dependency_links to src/pycountry.egg-info/dependency_links.txt
> writing top-level names to src/pycountry.egg-info/top_level.txt
> writing manifest file 'src/pycountry.egg-info/SOURCES.txt'
> reading manifest file 'src/pycountry.egg-info/SOURCES.txt'
> reading manifest template 'MANIFEST.in'
> warning: no previously-included files matching '*.py[co]' found anywhere in distribution
> adding license file 'LICENSE.txt'
> writing manifest file 'src/pycountry.egg-info/SOURCES.txt'
> creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build/pycountry/tests
> copying src/pycountry/tests/test_general.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build/pycountry/tests
> dh_auto_test -O--buildsystem=pybuild
> I: pybuild base:232: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build; python3.9 -m pytest /<<PKGBUILDDIR>>/src/pycountry/tests
> ============================= test session starts ==============================
> platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
> rootdir: /<<PKGBUILDDIR>>
> collected 20 items
>
> ../../../src/pycountry/tests/test_general.py .F..FF.......F..F... [100%]
>
> =================================== FAILURES ===================================
> __________________________ test_country_fuzzy_search ___________________________
>
> def test_country_fuzzy_search():
> > results = pycountry.countries.search_fuzzy(u'England')
>
> ../../../src/pycountry/tests/test_general.py:20:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pycountry.ExistingCountries object at 0x7f56b0ddaa30>, query = 'england'
>
> def search_fuzzy(self, query):
> query = remove_accents(query.strip().lower())
>
> # A country-code to points mapping for later sorting countries
> # based on the query's matching incidence.
> results = {}
>
> def add_result(country, points):
> results.setdefault(country.alpha_2, 0)
> results[country.alpha_2] += points
>
> # Prio 1: exact matches on country names
> try:
> add_result(self.lookup(query), 50)
> except LookupError:
> pass
>
> # Prio 2: exact matches on subdivision names
> for candidate in subdivisions:
> for v in candidate._fields.values():
> if v is None:
> continue
> v = remove_accents(v.lower())
> # Some names include alternative versions which we want to
> # match exactly.
> for v in v.split(';'):
> if v == query:
> add_result(candidate.country, 49)
> break
>
> # Prio 3: partial matches on country names
> for candidate in self:
> # Higher priority for a match on the common name
> for v in [candidate._fields.get('name'),
> candidate._fields.get('official_name'),
> candidate._fields.get('comment')]:
> if v is None:
> continue
> v = remove_accents(v.lower())
> if query in v:
> # This prefers countries with a match early in their name
> # and also balances against countries with a number of
> # partial matches and their name containing 'new' in the
> # middle
> add_result(candidate, max([5, 30-(2*v.find(query))]))
> break
>
> # Prio 4: partial matches on subdivision names
> for candidate in subdivisions:
> v = candidate._fields.get('name')
> if v is None:
> continue
> v = remove_accents(v.lower())
> if query in v:
> add_result(candidate.country, max([1, 5-v.find(query)]))
>
> if not results:
> > raise LookupError(query)
> E LookupError: england
>
> pycountry/__init__.py:93: LookupError
> ____________________ test_subdivisions_directly_accessible _____________________
>
> def test_subdivisions_directly_accessible():
> #assert len(pycountry.subdivisions) == 4883
> assert isinstance(list(pycountry.subdivisions)[0], pycountry.db.Data)
>
> de_st = pycountry.subdivisions.get(code='DE-ST')
> assert de_st.code == u'DE-ST'
> assert de_st.name == u'Sachsen-Anhalt'
> > assert de_st.type == u'State'
> E AssertionError: assert 'Land' == 'State'
> E - State
> E + Land
>
> ../../../src/pycountry/tests/test_general.py:80: AssertionError
> _________________ test_subdivisions_have_subdivision_as_parent _________________
>
> def test_subdivisions_have_subdivision_as_parent():
> al_bu = pycountry.subdivisions.get(code='AL-BU')
> > assert al_bu.code == u'AL-BU'
> E AttributeError: 'NoneType' object has no attribute 'code'
>
> ../../../src/pycountry/tests/test_general.py:88: AttributeError
> __________________________________ test_repr ___________________________________
>
> def test_repr():
> > assert re.match("Country\\(alpha_2=u?'DE', "
> "alpha_3=u?'DEU', "
> "name=u?'Germany', "
> "numeric=u?'276', "
> "official_name=u?'Federal Republic of Germany'\\)",
> repr(pycountry.countries.get(alpha_2='DE')))
> E assert None
> E + where None = <function match at 0x7f56b1a19ee0>("Country\\(alpha_2=u?'DE', alpha_3=u?'DEU', name=u?'Germany', numeric=u?'276', official_name=u?'Federal Republic of Germany'\\)", "Country(alpha_2='DE', alpha_3='DEU', flag='🇩🇪', name='Germany', numeric='276', official_name='Federal Republic of Germany')")
> E + where <function match at 0x7f56b1a19ee0> = re.match
> E + and "Country(alpha_2='DE', alpha_3='DEU', flag='🇩🇪', name='Germany', numeric='276', official_name='Federal Republic of Germany')" = repr(Country(alpha_2='DE', alpha_3='DEU', flag='🇩🇪', name='Germany', numeric='276', official_name='Federal Republic of Germany'))
> E + where Country(alpha_2='DE', alpha_3='DEU', flag='🇩🇪', name='Germany', numeric='276', official_name='Federal Republic of Germany') = <bound method lazy_load.<locals>.load_if_needed of <pycountry.ExistingCountries object at 0x7f56b0ddaa30>>(alpha_2='DE')
> E + where <bound method lazy_load.<locals>.load_if_needed of <pycountry.ExistingCountries object at 0x7f56b0ddaa30>> = <pycountry.ExistingCountries object at 0x7f56b0ddaa30>.get
> E + where <pycountry.ExistingCountries object at 0x7f56b0ddaa30> = pycountry.countries
>
> ../../../src/pycountry/tests/test_general.py:165: AssertionError
> _________________________________ test_lookup __________________________________
>
> def test_lookup():
> c = pycountry.countries
> g = c.get(alpha_2='DE')
> assert g == c.get(alpha_2='de')
> assert g == c.lookup('de')
> assert g == c.lookup('DEU')
> assert g == c.lookup('276')
> assert g == c.lookup('germany')
> assert g == c.lookup('Federal Republic of Germany')
> # try a generated field
> bqaq = pycountry.historic_countries.get(alpha_4='BQAQ')
> assert bqaq == pycountry.historic_countries.lookup('atb')
> german = pycountry.languages.get(alpha_2='de')
> assert german == pycountry.languages.lookup('De')
> euro = pycountry.currencies.get(alpha_3='EUR')
> assert euro == pycountry.currencies.lookup('euro')
> latin = pycountry.scripts.get(name='Latin')
> assert latin == pycountry.scripts.lookup('latn')
> al_bu = pycountry.subdivisions.get(code='AL-BU')
> > assert al_bu == pycountry.subdivisions.lookup('al-bu')
>
> ../../../src/pycountry/tests/test_general.py:208:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pycountry/db.py:51: in load_if_needed
> return f(self, *args, **kw)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pycountry.Subdivisions object at 0x7f56b0dda910>, value = 'al-bu'
>
> @lazy_load
> def lookup(self, value):
> if not isinstance(value, str):
> raise LookupError()
>
> # Normalize for case-insensitivity
> value = value.lower()
>
> # Use indexes first
> for key in self.indices:
> try:
> return self.indices[key][value]
> except LookupError:
> pass
>
> # Use non-indexed values now. Avoid going through indexed values.
> for candidate in self:
> for k in self.no_index:
> v = candidate._fields.get(k)
> if v is None:
> continue
> if v.lower() == value:
> return candidate
>
> > raise LookupError('Could not find a record for %r' % value)
> E LookupError: Could not find a record for 'al-bu'
>
> pycountry/db.py:156: LookupError
> =========================== short test summary info ============================
> FAILED ../../../src/pycountry/tests/test_general.py::test_country_fuzzy_search
> FAILED ../../../src/pycountry/tests/test_general.py::test_subdivisions_directly_accessible
> FAILED ../../../src/pycountry/tests/test_general.py::test_subdivisions_have_subdivision_as_parent
> FAILED ../../../src/pycountry/tests/test_general.py::test_repr - assert None
> FAILED ../../../src/pycountry/tests/test_general.py::test_lookup - LookupErro...
> ========================= 5 failed, 15 passed in 0.30s =========================
> E: pybuild pybuild:354: test: plugin distutils failed with: exit code=1: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pycountry/build; python3.9 -m pytest /<<PKGBUILDDIR>>/src/pycountry/tests
> dh_auto_test: error: pybuild --test -i python{version} -p 3.9 returned exit code 13

The full build log is available from:
http://qa-logs.debian.net/2021/11/04/pycountry_20.7.3+ds1-1_unstable.log

A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!

If you reassign this bug to another package, please marking it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.

Revision history for this message
Brian Murray (brian-murray) wrote :

There is an upstream merge proposal here:

https://github.com/flyingcircusio/pycountry/pull/86

tags: added: update-excuse
Changed in pycountry (Debian):
importance: Undecided → Unknown
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pycountry - 20.7.3+ds1-1ubuntu1

---------------
pycountry (20.7.3+ds1-1ubuntu1) jammy; urgency=medium

  * debian/patches/iso-codes-4.8.patch: resolve test failures with iso-codes
    version 4.8.0-1. (LP: #1953072)

 -- Brian Murray <email address hidden> Tue, 14 Dec 2021 15:36:00 -0800

Changed in pycountry (Ubuntu):
status: New → Fix Released
Changed in pycountry (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.