mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 02:16:52 +00:00
Merge pull request #236 from pre-commit/use_symlink_fixtures
Use fixtures for the symlink tests to fix appveyor
This commit is contained in:
commit
08a643e0de
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
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue