Skip to content

Commit 9c4ef89

Browse files
committed
add utils module tests
1 parent c1170c8 commit 9c4ef89

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import re
3+
4+
from fdiff.utils import get_file_modtime, file_exists
5+
6+
import pytest
7+
8+
9+
def test_get_file_modtime():
10+
modtime = get_file_modtime(os.path.join("tests", "testfiles", "test.txt"))
11+
assert modtime.startswith("2019-09-04T") is True
12+
regex = re.compile(r"""\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+-\d{2}:\d{2}""")
13+
assert regex.fullmatch(modtime) is not None
14+
15+
16+
def test_file_exists_true():
17+
assert file_exists(os.path.join("tests", "testfiles", "test.txt")) is True
18+
19+
20+
def test_file_exists_false():
21+
assert file_exists(os.path.join("tests", "testfiles", "bogus.jpg")) is False

0 commit comments

Comments
 (0)