mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 21:04:17 +00:00
Use fixtures for the symlink tests to fix appveyor
This commit is contained in:
parent
9730eb3beb
commit
c5b7c35d81
3 changed files with 14 additions and 11 deletions
|
|
@ -1 +0,0 @@
|
||||||
does_not_exist
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
does_exist
|
|
||||||
|
|
@ -3,16 +3,21 @@ import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pre_commit_hooks.check_symlinks import check_symlinks
|
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(
|
@pytest.mark.parametrize(
|
||||||
('filename', 'expected_retval'), (
|
('dest', 'expected'), (('exists', 0), ('does-not-exist', 1)),
|
||||||
('broken_symlink', 1),
|
|
||||||
('working_symlink', 0),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
def test_check_symlinks(filename, expected_retval):
|
def test_check_symlinks(tmpdir, dest, expected): # pragma: no cover (symlinks)
|
||||||
ret = check_symlinks([get_resource_path(filename)])
|
tmpdir.join('exists').ensure()
|
||||||
assert ret == expected_retval
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue