Skip to content

Commit

Permalink
Clean up unit tests for parsing and transforming edtf dates
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Apr 19, 2024
1 parent f66c6f0 commit 6221946
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
16 changes: 7 additions & 9 deletions tests/test_dateformat/edtf/test_edtf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
]


def test_should_parse():
for testcase in testcases:
tree = edtf_parser.parse(testcase)
assert tree
print(tree.pretty())
@pytest.mark.parametrize("date_string", testcases)
def test_should_parse(date_string):
assert edtf_parser.parse(date_string)


error_cases = ["1984-13", "Y1702"]


def test_should_error():
for error_case in error_cases:
with pytest.raises(Exception):
edtf_parser.parse(error_cases)
@pytest.mark.parametrize("date_string", error_cases)
def test_should_error(date_string):
with pytest.raises(Exception):
edtf_parser.parse(date_string)
19 changes: 5 additions & 14 deletions tests/test_dateformat/edtf/test_edtf_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,9 @@
]


def test_transform():
@pytest.mark.parametrize("date_string,expected", testcases)
def test_transform(date_string, expected):
transformer = EDTFTransformer()

for testinput, output in testcases:
parsetree = edtf_parser.parse(testinput)
assert transformer.transform(parsetree) == output


# error_cases = ["1984-13", "Y1702"]


# def test_should_error():
# for error_case in error_cases:
# with pytest.raises(Exception):
# edtf_parser.parse(error_cases)
# parse the input string, then transform to undate object
parsetree = edtf_parser.parse(date_string)
assert transformer.transform(parsetree) == expected

0 comments on commit 6221946

Please sign in to comment.