From b7cd5cfa14964aa32880ace16bccc341dfb2e144 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 5 Feb 2018 16:53:54 +0100 Subject: [PATCH] fix tests and compare return value --- dotdrop/dotdrop.py | 8 +++++--- tests/test_compare.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 0f4cfe6..6840bcf 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -112,17 +112,19 @@ def install(opts, conf): def compare(opts, conf, tmp, focus=None): + '''compare dotfiles and return True if all same''' dotfiles = conf.get_dotfiles(opts['profile']) if dotfiles == []: LOG.err('no dotfiles defined for this profile (\"%s\")' % (str(opts['profile']))) - return False + return True t = Templategen(base=opts['dotpath']) inst = Installer(create=opts['create'], backup=opts['backup'], dry=opts['dry'], base=opts['dotpath'], quiet=opts['quiet']) # compare only specific files + ret = True selected = dotfiles if focus: selected = [] @@ -132,11 +134,11 @@ def compare(opts, conf, tmp, focus=None): selected.append(df) else: LOG.err('no dotfile matches \"%s\"' % (selection)) + ret = False if len(selected) < 1: - return True + return ret - ret = True for dotfile in selected: same, diff = inst.compare(t, tmp, opts['profile'], dotfile.src, dotfile.dst, diff --git a/tests/test_compare.py b/tests/test_compare.py index 7b54a39..89729a0 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -135,9 +135,9 @@ class TestCompare(unittest.TestCase): self.assertTrue(results == expected) # test compare from dotdrop - self.assertTrue(compare(opts, conf, tmp)) + self.assertFalse(compare(opts, conf, tmp)) # test focus - self.assertTrue(compare(opts, conf, tmp, focus=d4)) + self.assertFalse(compare(opts, conf, tmp, focus=d4)) self.assertFalse(compare(opts, conf, tmp, focus='/tmp/fake'))