-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_test_utils.py
46 lines (38 loc) · 1.21 KB
/
test_test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import attr
import pytest
from scantree import DirEntryReplacement
from scantree.test_utils import assert_dir_entry_equal
class MockStat:
def __init__(self, st_ino=None):
self.st_ino = st_ino
class TestAssertDirEntryEqual:
def get_mock_dir_entry(self):
de = DirEntryReplacement(path="/path/to/mock", name="mock")
de._is_dir = True
de._is_file = False
de._is_symlink = False
de._stat_sym = MockStat(1)
de._stat_nosym = MockStat(0)
return de
def test_equal(self):
de = self.get_mock_dir_entry()
assert_dir_entry_equal(de, de)
@pytest.mark.parametrize(
"kwargs",
[
{"path": "other/path"},
{"name": "other_name"},
{"_is_dir": False},
{"_is_file": True},
{"_is_symlink": True},
{"_stat_sym": MockStat(11)},
{"_stat_nosym": MockStat(22)},
],
)
def test_not_equal(self, kwargs):
de = self.get_mock_dir_entry()
de_different = attr.evolve(de)
for k, v in kwargs.items():
setattr(de_different, k, v)
with pytest.raises(AssertionError):
assert_dir_entry_equal(de, de_different)