Skip to content

Commit b6bd1bf

Browse files
authored
fix windows unit tests
1 parent 60b7fac commit b6bd1bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/test_parse_git_ignore_revs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from mkdocs_git_revision_date_localized_plugin.util import Util
22
import pytest
33
import tempfile
4+
import os
45

56
TEST_PARAMS = [
67
("abc123\n", ["abc123"]),
@@ -10,7 +11,10 @@
1011

1112
@pytest.mark.parametrize("test_input,expected", TEST_PARAMS)
1213
def test_parse_git_ignore_revs(test_input, expected):
13-
with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8') as fp:
14+
with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', delete=False) as fp:
1415
fp.write(test_input)
15-
fp.flush()
16-
assert Util.parse_git_ignore_revs(fp.name) == expected
16+
temp_file_name = fp.name
17+
try:
18+
assert Util.parse_git_ignore_revs(temp_file_name) == expected
19+
finally:
20+
os.remove(temp_file_name)

0 commit comments

Comments
 (0)