diff --git a/tests/test_extract_odf_links.py b/tests/test_extract_odf_links.py index b236cd6bfcf0a31d507c25bd44444fee9342ed56..46619ae30af84e332f8de5ab8d00164fbbf16989 100644 --- a/tests/test_extract_odf_links.py +++ b/tests/test_extract_odf_links.py @@ -18,18 +18,26 @@ import io import pytest +from pathlib import Path + from . import testutil from conservancy_beancount.tools import extract_odf_links SRC_PATH = testutil.test_path('repository/LinksReport.ods') -EXPECTED_FILE_LINKS = { - '/repository/Projects/project-data.yml', - str(testutil.test_path('repository/Projects/project-data.yml')), - str(testutil.test_path('repository/Projects/Bad Link.txt')), +INCLUDED_FILE_LINKS = { + Path('/repository/Projects/project-data.yml'), + Path('Projects/project-data.yml'), + Path('Projects/Bad Link.txt'), } +def expected_links(rel_path): + return frozenset( + str(path if path.is_absolute() else rel_path / path) + for path in INCLUDED_FILE_LINKS + ) + @pytest.mark.parametrize('arglist,sep', [ (['-0'], '\0'), (['-d', '\\v'], '\v'), @@ -45,8 +53,9 @@ def test_extract_file_links(arglist, sep, caplog): actual = stdout.getvalue().split(sep) if actual and not actual[-1]: actual.pop() - assert len(actual) == len(EXPECTED_FILE_LINKS) - assert set(actual) == EXPECTED_FILE_LINKS + expected = expected_links(SRC_PATH.parent) + assert len(actual) == len(expected) + assert set(actual) == expected assert caplog.records assert any( log.levelname == 'WARNING'