Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More tests #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/src/unece_excel_parser/lib/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Normalizer:
]

@staticmethod
def is_empty(text: str) -> bool:
def is_empty(text: any) -> bool:
return text is None or str(text) == "nan" or str(text) == ""

@staticmethod
Expand Down
1 change: 0 additions & 1 deletion python/src/unece_excel_parser/unece_excel_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from lib.constants import PANDAS_STR_NA_VALUES_CUSTOMIZED
from lib.unit import Unit
from lib.units_analyzer import UnitsAnalyzer
from lib.normalizer import Normalizer


def read_rec20(path):
Expand Down
9 changes: 7 additions & 2 deletions python/tests/test_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from lib.normalizer import Normalizer
import pytest

def test_is_empty_given_empty_string_returns_true():
assert Normalizer.is_empty('') == True
@pytest.mark.parametrize(
"text_input,expected",
[("", True), ("nan", True), (None, True), (" ", True), ("a", False), ("1", False)],
)
def test_is_empty_given_empty_value_returns_true(text_input: str | None, expected: bool):
assert Normalizer.is_empty(text_input) is expected