Blob Blame History Raw
From e381259d5d59b5b19946eb0810eeb78071422c18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Mon, 4 Jul 2022 12:23:41 +0200
Subject: [PATCH] Replace exact-value asserts of the lengths of some data with
 approximates

With iso-codes 4.10+, the number of subdivisions and currencies changed
the tests have asserts for exact values. Debian removed the asserts.
Instead, we change the asserts to be approximates.
If this proves to be too problematic in the future, we can go the Debian way.
---

diff --git a/src/pycountry/tests/test_general.py b/src/pycountry/tests/test_general.py
index 749859e..ec3e1f5 100644
--- a/src/pycountry/tests/test_general.py
+++ b/src/pycountry/tests/test_general.py
@@ -76,7 +76,7 @@ def test_germany_has_all_attributes():
 
 
 def test_subdivisions_directly_accessible():
-    assert len(pycountry.subdivisions) == 5123
+    assert len(pycountry.subdivisions) == pytest.approx(5123, rel=0.1)
     assert isinstance(list(pycountry.subdivisions)[0], pycountry.db.Data)
 
     de_st = pycountry.subdivisions.get(code="DE-ST")
@@ -104,7 +104,7 @@ def test_query_subdivisions_of_country():
 
 
 def test_scripts():
-    assert len(pycountry.scripts) == 182
+    assert len(pycountry.scripts) == pytest.approx(182, rel=0.1)
     assert isinstance(list(pycountry.scripts)[0], pycountry.db.Data)
 
     latin = pycountry.scripts.get(name="Latin")
@@ -114,7 +114,7 @@ def test_scripts():
 
 
 def test_currencies():
-    assert len(pycountry.currencies) == 170
+    assert len(pycountry.currencies) == pytest.approx(170, rel=0.1)
     assert isinstance(list(pycountry.currencies)[0], pycountry.db.Data)
 
     argentine_peso = pycountry.currencies.get(alpha_3="ARS")
@@ -124,7 +124,7 @@ def test_currencies():
 
 
 def test_languages():
-    assert len(pycountry.languages) == 7847
+    assert len(pycountry.languages) == pytest.approx(7847, rel=0.1)
     assert isinstance(list(pycountry.languages)[0], pycountry.db.Data)
 
     aragonese = pycountry.languages.get(alpha_2="an")

-- 
2.35.3