Use fixtures for the symlink tests to fix appveyor

This commit is contained in:
Anthony Sottile
2017-09-08 08:27:04 -07:00
parent 9730eb3beb
commit c5b7c35d81
3 changed files with 14 additions and 11 deletions

View File

@ -1 +0,0 @@
does_not_exist

View File

@ -1 +0,0 @@
does_exist

View File

@ -3,16 +3,21 @@ import os
import pytest
from pre_commit_hooks.check_symlinks import check_symlinks
from testing.util import get_resource_path
@pytest.mark.xfail(os.name == 'nt', reason='No symlink support on windows')
xfail_symlink = pytest.mark.xfail(os.name == 'nt', reason='No symlink support')
@xfail_symlink
@pytest.mark.parametrize(
('filename', 'expected_retval'), (
('broken_symlink', 1),
('working_symlink', 0),
),
('dest', 'expected'), (('exists', 0), ('does-not-exist', 1)),
)
def test_check_symlinks(filename, expected_retval):
ret = check_symlinks([get_resource_path(filename)])
assert ret == expected_retval
def test_check_symlinks(tmpdir, dest, expected): # pragma: no cover (symlinks)
tmpdir.join('exists').ensure()
symlink = tmpdir.join('symlink')
symlink.mksymlinkto(tmpdir.join(dest))
assert check_symlinks((symlink.strpath,)) == expected
def test_check_symlinks_normal_file(tmpdir):
assert check_symlinks((tmpdir.join('f').ensure().strpath,)) == 0