Skip to content

Commit e69782a

Browse files
authored
🐛 fix for locale constructor (#67)
1 parent 42d6371 commit e69782a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

mindee/fields/locale.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ def __init__(
3232

3333
@staticmethod
3434
def _get_value(locale_prediction, key: str):
35-
if (
36-
key not in locale_prediction.keys()
37-
or locale_prediction["language"] == "N/A"
38-
):
35+
if key not in locale_prediction or locale_prediction[key] == "N/A":
3936
return None
4037
return locale_prediction[key]
4138

tests/fields/test_locale.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ def test_constructor_almost_empty_field():
2323
assert locale.language is None
2424
assert locale.country is None
2525
assert locale.currency is None
26+
27+
28+
def test_constructor_empty_language():
29+
field_dict = {
30+
"value": "en-EN",
31+
"country": "uk",
32+
"currency": "GBP",
33+
"language": "N/A",
34+
"confidence": 0.1,
35+
}
36+
locale = Locale(field_dict)
37+
assert locale.language is None
38+
assert locale.country == "uk"
39+
assert locale.currency == "GBP"
40+
assert str(locale) == "en-EN; uk; GBP;"

0 commit comments

Comments
 (0)