mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-26 10:02:22 +08:00
Use fixtures for the symlink tests to fix appveyor
This commit is contained in:
@ -1 +0,0 @@
|
||||
does_not_exist
|
@ -1 +0,0 @@
|
||||
does_exist
|
@ -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
|
||||
|
Reference in New Issue
Block a user