From 190b99b39fa1a574c41d074e53821640ed08bedb Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Sat, 26 Dec 2015 14:44:27 -0500 Subject: Remove half-backed tests refactoring --- tests/conftest.py | 62 ------------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 tests/conftest.py (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 7fc2cc4..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import pytest -from dotfiles.utils import compare_path as samefile - - -def _touch(fname, times=None): - with open(fname, 'a'): - os.utime(fname, times) - - -class HomeDirectory(object): - - DEFAULT_REPOSITORY = 'dotfiles' - - def __init__(self, path, repo=None, contents=None): - self.path = path - if not repo: - self.repo = os.path.join(path, self.DEFAULT_REPOSITORY) - if contents: - self.setup(contents) - - def setup(self, contents): - repo = os.path.join(self.path, self.repo) - os.mkdir(repo) - - for link, link_should_exist in contents.items(): - - target = os.path.join('%s/%s' % (repo, link[1:])) - _touch(target) - - if link_should_exist: - os.symlink(target, os.path.join(self.path, link)) - - self.verify(contents) - - def verify(self, contents): - __tracebackhide__ = True - - for link, link_should_exist in contents.items(): - - target = os.path.join(self.path, '%s/%s' % (self.repo, link[1:])) - - if not os.path.exists(target): - pytest.fail("missing expected repo file \"%s\"" % target) - - link = os.path.join(self.path, link) - link_exists = os.path.exists(link) - - if link_should_exist: - if not link_exists: - pytest.fail("missing expected symlink \"%s\"" % link) - if not samefile(link, target): - pytest.fail("\"%s\" does not link to \"%s\"" % - (link, target)) - - elif link_exists: - pytest.fail("found unexpected symlink \"%s\"" % link) - - -@pytest.fixture -def homedir(tmpdir): - return HomeDirectory(str(tmpdir)) -- cgit v1.2.3