mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
More cleanup and fixed a flake8 build issue
This commit is contained in:
@@ -369,13 +369,13 @@ class TestCaseDupeGuruWithResults:
|
||||
open(p1, "w").close()
|
||||
open(p2, "w").close()
|
||||
dne = "/does_not_exist"
|
||||
app.ignore_list.Ignore(dne, p1)
|
||||
app.ignore_list.Ignore(p2, dne)
|
||||
app.ignore_list.Ignore(p1, p2)
|
||||
app.ignore_list.ignore(dne, p1)
|
||||
app.ignore_list.ignore(p2, dne)
|
||||
app.ignore_list.ignore(p1, p2)
|
||||
app.purge_ignore_list()
|
||||
eq_(1, len(app.ignore_list))
|
||||
assert app.ignore_list.AreIgnored(p1, p2)
|
||||
assert not app.ignore_list.AreIgnored(dne, p1)
|
||||
assert app.ignore_list.are_ignored(p1, p2)
|
||||
assert not app.ignore_list.are_ignored(dne, p1)
|
||||
|
||||
def test_only_unicode_is_added_to_ignore_list(self, do_setup):
|
||||
def fake_ignore(first, second):
|
||||
@@ -385,7 +385,7 @@ class TestCaseDupeGuruWithResults:
|
||||
self.fail()
|
||||
|
||||
app = self.app
|
||||
app.ignore_list.Ignore = fake_ignore
|
||||
app.ignore_list.ignore = fake_ignore
|
||||
self.rtable.select([4])
|
||||
app.add_selected_to_ignore_list()
|
||||
|
||||
|
||||
@@ -16,54 +16,54 @@ from ..ignore import IgnoreList
|
||||
def test_empty():
|
||||
il = IgnoreList()
|
||||
eq_(0, len(il))
|
||||
assert not il.AreIgnored("foo", "bar")
|
||||
assert not il.are_ignored("foo", "bar")
|
||||
|
||||
|
||||
def test_simple():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
assert il.AreIgnored("foo", "bar")
|
||||
assert il.AreIgnored("bar", "foo")
|
||||
assert not il.AreIgnored("foo", "bleh")
|
||||
assert not il.AreIgnored("bleh", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
assert il.are_ignored("foo", "bar")
|
||||
assert il.are_ignored("bar", "foo")
|
||||
assert not il.are_ignored("foo", "bleh")
|
||||
assert not il.are_ignored("bleh", "bar")
|
||||
eq_(1, len(il))
|
||||
|
||||
|
||||
def test_multiple():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("foo", "bleh")
|
||||
il.Ignore("bleh", "bar")
|
||||
il.Ignore("aybabtu", "bleh")
|
||||
assert il.AreIgnored("foo", "bar")
|
||||
assert il.AreIgnored("bar", "foo")
|
||||
assert il.AreIgnored("foo", "bleh")
|
||||
assert il.AreIgnored("bleh", "bar")
|
||||
assert not il.AreIgnored("aybabtu", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("foo", "bleh")
|
||||
il.ignore("bleh", "bar")
|
||||
il.ignore("aybabtu", "bleh")
|
||||
assert il.are_ignored("foo", "bar")
|
||||
assert il.are_ignored("bar", "foo")
|
||||
assert il.are_ignored("foo", "bleh")
|
||||
assert il.are_ignored("bleh", "bar")
|
||||
assert not il.are_ignored("aybabtu", "bar")
|
||||
eq_(4, len(il))
|
||||
|
||||
|
||||
def test_clear():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Clear()
|
||||
assert not il.AreIgnored("foo", "bar")
|
||||
assert not il.AreIgnored("bar", "foo")
|
||||
il.ignore("foo", "bar")
|
||||
il.clear()
|
||||
assert not il.are_ignored("foo", "bar")
|
||||
assert not il.are_ignored("bar", "foo")
|
||||
eq_(0, len(il))
|
||||
|
||||
|
||||
def test_add_same_twice():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("bar", "foo")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("bar", "foo")
|
||||
eq_(1, len(il))
|
||||
|
||||
|
||||
def test_save_to_xml():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("foo", "bleh")
|
||||
il.Ignore("bleh", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("foo", "bleh")
|
||||
il.ignore("bleh", "bar")
|
||||
f = io.BytesIO()
|
||||
il.save_to_xml(f)
|
||||
f.seek(0)
|
||||
@@ -79,17 +79,17 @@ def test_save_to_xml():
|
||||
|
||||
def test_save_then_load():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("foo", "bleh")
|
||||
il.Ignore("bleh", "bar")
|
||||
il.Ignore("\u00e9", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("foo", "bleh")
|
||||
il.ignore("bleh", "bar")
|
||||
il.ignore("\u00e9", "bar")
|
||||
f = io.BytesIO()
|
||||
il.save_to_xml(f)
|
||||
f.seek(0)
|
||||
il = IgnoreList()
|
||||
il.load_from_xml(f)
|
||||
eq_(4, len(il))
|
||||
assert il.AreIgnored("\u00e9", "bar")
|
||||
assert il.are_ignored("\u00e9", "bar")
|
||||
|
||||
|
||||
def test_load_xml_with_empty_file_tags():
|
||||
@@ -103,16 +103,16 @@ def test_load_xml_with_empty_file_tags():
|
||||
|
||||
def test_are_ignore_works_when_a_child_is_a_key_somewhere_else():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("bar", "baz")
|
||||
assert il.AreIgnored("bar", "foo")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("bar", "baz")
|
||||
assert il.are_ignored("bar", "foo")
|
||||
|
||||
|
||||
def test_no_dupes_when_a_child_is_a_key_somewhere_else():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("bar", "baz")
|
||||
il.Ignore("bar", "foo")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("bar", "baz")
|
||||
il.ignore("bar", "foo")
|
||||
eq_(2, len(il))
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ def test_iterate():
|
||||
il = IgnoreList()
|
||||
expected = [("foo", "bar"), ("bar", "baz"), ("foo", "baz")]
|
||||
for i in expected:
|
||||
il.Ignore(i[0], i[1])
|
||||
il.ignore(i[0], i[1])
|
||||
for i in il:
|
||||
expected.remove(i) # No exception should be raised
|
||||
assert not expected # expected should be empty
|
||||
@@ -129,18 +129,18 @@ def test_iterate():
|
||||
|
||||
def test_filter():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("bar", "baz")
|
||||
il.Ignore("foo", "baz")
|
||||
il.Filter(lambda f, s: f == "bar")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("bar", "baz")
|
||||
il.ignore("foo", "baz")
|
||||
il.filter(lambda f, s: f == "bar")
|
||||
eq_(1, len(il))
|
||||
assert not il.AreIgnored("foo", "bar")
|
||||
assert il.AreIgnored("bar", "baz")
|
||||
assert not il.are_ignored("foo", "bar")
|
||||
assert il.are_ignored("bar", "baz")
|
||||
|
||||
|
||||
def test_save_with_non_ascii_items():
|
||||
il = IgnoreList()
|
||||
il.Ignore("\xac", "\xbf")
|
||||
il.ignore("\xac", "\xbf")
|
||||
f = io.BytesIO()
|
||||
try:
|
||||
il.save_to_xml(f)
|
||||
@@ -151,29 +151,29 @@ def test_save_with_non_ascii_items():
|
||||
def test_len():
|
||||
il = IgnoreList()
|
||||
eq_(0, len(il))
|
||||
il.Ignore("foo", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
eq_(1, len(il))
|
||||
|
||||
|
||||
def test_nonzero():
|
||||
il = IgnoreList()
|
||||
assert not il
|
||||
il.Ignore("foo", "bar")
|
||||
il.ignore("foo", "bar")
|
||||
assert il
|
||||
|
||||
|
||||
def test_remove():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("foo", "baz")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("foo", "baz")
|
||||
il.remove("bar", "foo")
|
||||
eq_(len(il), 1)
|
||||
assert not il.AreIgnored("foo", "bar")
|
||||
assert not il.are_ignored("foo", "bar")
|
||||
|
||||
|
||||
def test_remove_non_existant():
|
||||
il = IgnoreList()
|
||||
il.Ignore("foo", "bar")
|
||||
il.Ignore("foo", "baz")
|
||||
il.ignore("foo", "bar")
|
||||
il.ignore("foo", "baz")
|
||||
with raises(ValueError):
|
||||
il.remove("foo", "bleh")
|
||||
|
||||
@@ -391,8 +391,8 @@ def test_ignore_list(fake_fileexists):
|
||||
f2.path = Path("dir2/foobar")
|
||||
f3.path = Path("dir3/foobar")
|
||||
ignore_list = IgnoreList()
|
||||
ignore_list.Ignore(str(f1.path), str(f2.path))
|
||||
ignore_list.Ignore(str(f1.path), str(f3.path))
|
||||
ignore_list.ignore(str(f1.path), str(f2.path))
|
||||
ignore_list.ignore(str(f1.path), str(f3.path))
|
||||
r = s.get_dupe_groups([f1, f2, f3], ignore_list=ignore_list)
|
||||
eq_(len(r), 1)
|
||||
g = r[0]
|
||||
@@ -415,8 +415,8 @@ def test_ignore_list_checks_for_unicode(fake_fileexists):
|
||||
f2.path = Path("foo2\u00e9")
|
||||
f3.path = Path("foo3\u00e9")
|
||||
ignore_list = IgnoreList()
|
||||
ignore_list.Ignore(str(f1.path), str(f2.path))
|
||||
ignore_list.Ignore(str(f1.path), str(f3.path))
|
||||
ignore_list.ignore(str(f1.path), str(f2.path))
|
||||
ignore_list.ignore(str(f1.path), str(f3.path))
|
||||
r = s.get_dupe_groups([f1, f2, f3], ignore_list=ignore_list)
|
||||
eq_(len(r), 1)
|
||||
g = r[0]
|
||||
|
||||
Reference in New Issue
Block a user