From c5b7c35d81174fa8e69c50f6561fa9537f1334e5 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 8 Sep 2017 08:27:04 -0700 Subject: [PATCH] Use fixtures for the symlink tests to fix appveyor --- testing/resources/broken_symlink | 1 - testing/resources/working_symlink | 1 - tests/check_symlinks_test.py | 23 ++++++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) delete mode 120000 testing/resources/broken_symlink delete mode 120000 testing/resources/working_symlink diff --git a/testing/resources/broken_symlink b/testing/resources/broken_symlink deleted file mode 120000 index ee1f6cb..0000000 --- a/testing/resources/broken_symlink +++ /dev/null @@ -1 +0,0 @@ -does_not_exist \ No newline at end of file diff --git a/testing/resources/working_symlink b/testing/resources/working_symlink deleted file mode 120000 index 20b5061..0000000 --- a/testing/resources/working_symlink +++ /dev/null @@ -1 +0,0 @@ -does_exist \ No newline at end of file diff --git a/tests/check_symlinks_test.py b/tests/check_symlinks_test.py index 19bb5b4..0414df5 100644 --- a/tests/check_symlinks_test.py +++ b/tests/check_symlinks_test.py @@ -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