Skip to content

Commit c5b7c35

Browse files
committed
Use fixtures for the symlink tests to fix appveyor
1 parent 9730eb3 commit c5b7c35

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

testing/resources/broken_symlink

Lines changed: 0 additions & 1 deletion
This file was deleted.

testing/resources/working_symlink

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/check_symlinks_test.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
import pytest
44

55
from pre_commit_hooks.check_symlinks import check_symlinks
6-
from testing.util import get_resource_path
76

87

9-
@pytest.mark.xfail(os.name == 'nt', reason='No symlink support on windows')
8+
xfail_symlink = pytest.mark.xfail(os.name == 'nt', reason='No symlink support')
9+
10+
11+
@xfail_symlink
1012
@pytest.mark.parametrize(
11-
('filename', 'expected_retval'), (
12-
('broken_symlink', 1),
13-
('working_symlink', 0),
14-
),
13+
('dest', 'expected'), (('exists', 0), ('does-not-exist', 1)),
1514
)
16-
def test_check_symlinks(filename, expected_retval):
17-
ret = check_symlinks([get_resource_path(filename)])
18-
assert ret == expected_retval
15+
def test_check_symlinks(tmpdir, dest, expected): # pragma: no cover (symlinks)
16+
tmpdir.join('exists').ensure()
17+
symlink = tmpdir.join('symlink')
18+
symlink.mksymlinkto(tmpdir.join(dest))
19+
assert check_symlinks((symlink.strpath,)) == expected
20+
21+
22+
def test_check_symlinks_normal_file(tmpdir):
23+
assert check_symlinks((tmpdir.join('f').ensure().strpath,)) == 0

0 commit comments

Comments
 (0)