mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-11-19 21:39:02 +00:00
Moved the tests to a "tests" subfolder, and "un-unittest"'ed some of them.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4025
This commit is contained in:
parent
9c1473b877
commit
1f72e2a6be
@ -1,158 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Unit Name: ignore
|
|
||||||
Created By: Virgil Dupras
|
|
||||||
Created On: 2006/05/02
|
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
import cStringIO
|
|
||||||
import xml.dom.minidom
|
|
||||||
|
|
||||||
from .ignore import *
|
|
||||||
|
|
||||||
class TCIgnoreList(unittest.TestCase):
|
|
||||||
def test_empty(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
self.assertEqual(0,len(il))
|
|
||||||
self.assert_(not il.AreIgnored('foo','bar'))
|
|
||||||
|
|
||||||
def test_simple(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
self.assert_(il.AreIgnored('foo','bar'))
|
|
||||||
self.assert_(il.AreIgnored('bar','foo'))
|
|
||||||
self.assert_(not il.AreIgnored('foo','bleh'))
|
|
||||||
self.assert_(not il.AreIgnored('bleh','bar'))
|
|
||||||
self.assertEqual(1,len(il))
|
|
||||||
|
|
||||||
def test_multiple(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('foo','bleh')
|
|
||||||
il.Ignore('bleh','bar')
|
|
||||||
il.Ignore('aybabtu','bleh')
|
|
||||||
self.assert_(il.AreIgnored('foo','bar'))
|
|
||||||
self.assert_(il.AreIgnored('bar','foo'))
|
|
||||||
self.assert_(il.AreIgnored('foo','bleh'))
|
|
||||||
self.assert_(il.AreIgnored('bleh','bar'))
|
|
||||||
self.assert_(not il.AreIgnored('aybabtu','bar'))
|
|
||||||
self.assertEqual(4,len(il))
|
|
||||||
|
|
||||||
def test_clear(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Clear()
|
|
||||||
self.assert_(not il.AreIgnored('foo','bar'))
|
|
||||||
self.assert_(not il.AreIgnored('bar','foo'))
|
|
||||||
self.assertEqual(0,len(il))
|
|
||||||
|
|
||||||
def test_add_same_twice(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('bar','foo')
|
|
||||||
self.assertEqual(1,len(il))
|
|
||||||
|
|
||||||
def test_save_to_xml(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('foo','bleh')
|
|
||||||
il.Ignore('bleh','bar')
|
|
||||||
f = cStringIO.StringIO()
|
|
||||||
il.save_to_xml(f)
|
|
||||||
f.seek(0)
|
|
||||||
doc = xml.dom.minidom.parse(f)
|
|
||||||
root = doc.documentElement
|
|
||||||
self.assertEqual('ignore_list',root.nodeName)
|
|
||||||
children = [c for c in root.childNodes if c.localName]
|
|
||||||
self.assertEqual(2,len(children))
|
|
||||||
self.assertEqual(2,len([c for c in children if c.nodeName == 'file']))
|
|
||||||
f1,f2 = children
|
|
||||||
subchildren = [c for c in f1.childNodes if c.localName == 'file'] +\
|
|
||||||
[c for c in f2.childNodes if c.localName == 'file']
|
|
||||||
self.assertEqual(3,len(subchildren))
|
|
||||||
|
|
||||||
def test_SaveThenLoad(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('foo','bleh')
|
|
||||||
il.Ignore('bleh','bar')
|
|
||||||
il.Ignore(u'\u00e9','bar')
|
|
||||||
f = cStringIO.StringIO()
|
|
||||||
il.save_to_xml(f)
|
|
||||||
f.seek(0)
|
|
||||||
il = IgnoreList()
|
|
||||||
il.load_from_xml(f)
|
|
||||||
self.assertEqual(4,len(il))
|
|
||||||
self.assert_(il.AreIgnored(u'\u00e9','bar'))
|
|
||||||
|
|
||||||
def test_LoadXML_with_empty_file_tags(self):
|
|
||||||
f = cStringIO.StringIO()
|
|
||||||
f.write('<?xml version="1.0" encoding="utf-8"?><ignore_list><file><file/></file></ignore_list>')
|
|
||||||
f.seek(0)
|
|
||||||
il = IgnoreList()
|
|
||||||
il.load_from_xml(f)
|
|
||||||
self.assertEqual(0,len(il))
|
|
||||||
|
|
||||||
def test_AreIgnore_works_when_a_child_is_a_key_somewhere_else(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('bar','baz')
|
|
||||||
self.assert_(il.AreIgnored('bar','foo'))
|
|
||||||
|
|
||||||
|
|
||||||
def test_no_dupes_when_a_child_is_a_key_somewhere_else(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('bar','baz')
|
|
||||||
il.Ignore('bar','foo')
|
|
||||||
self.assertEqual(2,len(il))
|
|
||||||
|
|
||||||
def test_iterate(self):
|
|
||||||
#It must be possible to iterate through ignore list
|
|
||||||
il = IgnoreList()
|
|
||||||
expected = [('foo','bar'),('bar','baz'),('foo','baz')]
|
|
||||||
for i in expected:
|
|
||||||
il.Ignore(i[0],i[1])
|
|
||||||
for i in il:
|
|
||||||
expected.remove(i) #No exception should be raised
|
|
||||||
self.assert_(not expected) #expected should be empty
|
|
||||||
|
|
||||||
def test_filter(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
il.Ignore('bar','baz')
|
|
||||||
il.Ignore('foo','baz')
|
|
||||||
il.Filter(lambda f,s: f == 'bar')
|
|
||||||
self.assertEqual(1,len(il))
|
|
||||||
self.assert_(not il.AreIgnored('foo','bar'))
|
|
||||||
self.assert_(il.AreIgnored('bar','baz'))
|
|
||||||
|
|
||||||
def test_save_with_non_ascii_non_unicode_items(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
il.Ignore('\xac','\xbf')
|
|
||||||
f = cStringIO.StringIO()
|
|
||||||
try:
|
|
||||||
il.save_to_xml(f)
|
|
||||||
except Exception,e:
|
|
||||||
self.fail(str(e))
|
|
||||||
|
|
||||||
def test_len(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
self.assertEqual(0,len(il))
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
self.assertEqual(1,len(il))
|
|
||||||
|
|
||||||
def test_nonzero(self):
|
|
||||||
il = IgnoreList()
|
|
||||||
self.assert_(not il)
|
|
||||||
il.Ignore('foo','bar')
|
|
||||||
self.assert_(il)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
|
|
0
py/tests/__init__.py
Normal file
0
py/tests/__init__.py
Normal file
@ -1,13 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.app_cocoa_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.app_cocoa
|
# Created On: 2006/11/11
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/11/11
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-29 17:51:41 +0200 (Fri, 29 May 2009) $
|
|
||||||
$Revision: 4409 $
|
|
||||||
Copyright 2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
@ -18,13 +14,13 @@ from hsutil.decorators import log_calls
|
|||||||
import hsfs.phys
|
import hsfs.phys
|
||||||
import os.path as op
|
import os.path as op
|
||||||
|
|
||||||
from . import engine, data
|
from .results_test import GetTestGroups
|
||||||
|
from .. import engine, data
|
||||||
try:
|
try:
|
||||||
from .app_cocoa import DupeGuru as DupeGuruBase, DGDirectory
|
from ..app_cocoa import DupeGuru as DupeGuruBase, DGDirectory
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
raise SkipTest("These tests can only be run on OS X")
|
raise SkipTest("These tests can only be run on OS X")
|
||||||
from .results_test import GetTestGroups
|
|
||||||
|
|
||||||
class DupeGuru(DupeGuruBase):
|
class DupeGuru(DupeGuruBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
@ -1,14 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.app_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.app
|
# Created On: 2007-06-23
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2007-06-23
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4388 $
|
|
||||||
Copyright 2007 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from hsutil.testcase import TestCase
|
from hsutil.testcase import TestCase
|
||||||
@ -20,8 +15,8 @@ import hsfs.phys
|
|||||||
import hsutil.files
|
import hsutil.files
|
||||||
from hsutil.job import nulljob
|
from hsutil.job import nulljob
|
||||||
|
|
||||||
from . import data, app
|
from .. import data, app
|
||||||
from .app import DupeGuru as DupeGuruBase
|
from ..app import DupeGuru as DupeGuruBase
|
||||||
|
|
||||||
class DupeGuru(DupeGuruBase):
|
class DupeGuru(DupeGuruBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -132,6 +127,3 @@ class TCDupeGuru_clean_empty_dirs(TestCase):
|
|||||||
self.assertEqual(Path('not-empty/empty'), calls[1]['path'])
|
self.assertEqual(Path('not-empty/empty'), calls[1]['path'])
|
||||||
self.assertEqual(Path('not-empty'), calls[2]['path'])
|
self.assertEqual(Path('not-empty'), calls[2]['path'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
@ -1,17 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: tests.picture.block
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: tests.picture.block
|
# Created On: 2006/09/01
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/09/01
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
# The commented out tests are tests for function that have been converted to pure C for speed
|
# The commented out tests are tests for function that have been converted to pure C for speed
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from .block import *
|
from ..picture.block import *
|
||||||
|
|
||||||
def my_avgdiff(first, second, limit=768, min_iter=3): # this is so I don't have to re-write every call
|
def my_avgdiff(first, second, limit=768, min_iter=3): # this is so I don't have to re-write every call
|
||||||
return avgdiff(first, second, limit, min_iter)
|
return avgdiff(first, second, limit, min_iter)
|
||||||
@ -307,7 +303,4 @@ class TCavgdiff(unittest.TestCase):
|
|||||||
# expected1 = 5 + 10 + 15
|
# expected1 = 5 + 10 + 15
|
||||||
# expected2 = 0 + 250 + 10
|
# expected2 = 0 + 250 + 10
|
||||||
# self.assertEqual(expected1,maxdiff(blocks1,blocks2,expected1 - 1))
|
# self.assertEqual(expected1,maxdiff(blocks1,blocks2,expected1 - 1))
|
||||||
#
|
#
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,23 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.cache_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: tests.picture.cache
|
# Created On: 2006/09/14
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/09/14
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
import os.path as op
|
import os.path as op
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from hsutil.testcase import TestCase
|
from hsutil.testcase import TestCase
|
||||||
from .cache import *
|
|
||||||
|
|
||||||
class TCcolors_to_string(unittest.TestCase):
|
from ..picture.cache import *
|
||||||
|
|
||||||
|
class TCcolors_to_string(TestCase):
|
||||||
def test_no_color(self):
|
def test_no_color(self):
|
||||||
self.assertEqual('',colors_to_string([]))
|
self.assertEqual('',colors_to_string([]))
|
||||||
|
|
||||||
@ -30,7 +26,7 @@ class TCcolors_to_string(unittest.TestCase):
|
|||||||
self.assertEqual('000102030405',colors_to_string([(0,1,2),(3,4,5)]))
|
self.assertEqual('000102030405',colors_to_string([(0,1,2),(3,4,5)]))
|
||||||
|
|
||||||
|
|
||||||
class TCstring_to_colors(unittest.TestCase):
|
class TCstring_to_colors(TestCase):
|
||||||
def test_empty(self):
|
def test_empty(self):
|
||||||
self.assertEqual([],string_to_colors(''))
|
self.assertEqual([],string_to_colors(''))
|
||||||
|
|
||||||
@ -118,7 +114,7 @@ class TCCache(TestCase):
|
|||||||
self.assertEqual(c[foo_id], b)
|
self.assertEqual(c[foo_id], b)
|
||||||
|
|
||||||
|
|
||||||
class TCCacheSQLEscape(unittest.TestCase):
|
class TCCacheSQLEscape(TestCase):
|
||||||
def test_contains(self):
|
def test_contains(self):
|
||||||
c = Cache()
|
c = Cache()
|
||||||
self.assert_("foo'bar" not in c)
|
self.assert_("foo'bar" not in c)
|
||||||
@ -140,7 +136,7 @@ class TCCacheSQLEscape(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
class TCCacheThreaded(unittest.TestCase):
|
class TCCacheThreaded(TestCase):
|
||||||
def test_access_cache(self):
|
def test_access_cache(self):
|
||||||
def thread_run():
|
def thread_run():
|
||||||
try:
|
try:
|
||||||
@ -154,6 +150,3 @@ class TCCacheThreaded(unittest.TestCase):
|
|||||||
t.join()
|
t.join()
|
||||||
self.assertEqual([(1,2,3)], c['foo'])
|
self.assertEqual([(1,2,3)], c['foo'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,14 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.directories_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.directories
|
# Created On: 2006/02/27
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/02/27
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-29 08:51:14 +0200 (Fri, 29 May 2009) $
|
|
||||||
$Revision: 4398 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
import os.path as op
|
import os.path as op
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -20,7 +15,7 @@ from hsutil.testcase import TestCase
|
|||||||
import hsfs.phys
|
import hsfs.phys
|
||||||
from hsfs.phys import phys_test
|
from hsfs.phys import phys_test
|
||||||
|
|
||||||
from directories import *
|
from ..directories import *
|
||||||
|
|
||||||
testpath = Path(TestCase.datadirpath())
|
testpath = Path(TestCase.datadirpath())
|
||||||
|
|
||||||
@ -275,6 +270,3 @@ class TCDirectories(TestCase):
|
|||||||
self.assert_(isinstance(d.add_path(p2), hsfs.phys.Directory))
|
self.assert_(isinstance(d.add_path(p2), hsfs.phys.Directory))
|
||||||
self.assert_(isinstance(d.add_path(p1), MySpecialDirclass))
|
self.assert_(isinstance(d.add_path(p1), MySpecialDirclass))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,22 +1,17 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.engine_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.engine_test
|
# Created On: 2006/01/29
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/01/29
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: $
|
|
||||||
$Revision: $
|
|
||||||
Copyright 2004-2008 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from hsutil import job
|
from hsutil import job
|
||||||
from hsutil.decorators import log_calls
|
from hsutil.decorators import log_calls
|
||||||
from hsutil.testcase import TestCase
|
from hsutil.testcase import TestCase
|
||||||
|
|
||||||
from . import engine
|
from .. import engine
|
||||||
from .engine import *
|
from ..engine import *
|
||||||
|
|
||||||
class NamedObject(object):
|
class NamedObject(object):
|
||||||
def __init__(self, name="foobar", with_words=False):
|
def __init__(self, name="foobar", with_words=False):
|
||||||
@ -817,6 +812,3 @@ class TCget_groups(TestCase):
|
|||||||
self.assertEqual(0,self.log[0])
|
self.assertEqual(0,self.log[0])
|
||||||
self.assertEqual(100,self.log[-1])
|
self.assertEqual(100,self.log[-1])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,21 +1,16 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.export_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.export
|
# Created On: 2006/09/16
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/09/16
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
from hsutil.testcase import TestCase
|
from hsutil.testcase import TestCase
|
||||||
|
|
||||||
from .export import *
|
from .. import export
|
||||||
from . import export
|
from ..export import *
|
||||||
|
|
||||||
class TCoutput_columns_xml(TestCase):
|
class TCoutput_columns_xml(TestCase):
|
||||||
def test_empty_columns(self):
|
def test_empty_columns(self):
|
||||||
@ -86,6 +81,3 @@ class TCmerge_css_into_xhtml(TestCase):
|
|||||||
xhtml.seek(0)
|
xhtml.seek(0)
|
||||||
self.assert_(not merge_css_into_xhtml(xhtml,StringIO()))
|
self.assert_(not merge_css_into_xhtml(xhtml,StringIO()))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
149
py/tests/ignore_test.py
Normal file
149
py/tests/ignore_test.py
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
# Unit Name: dupeguru.tests.ignore_test
|
||||||
|
# Created By: Virgil Dupras
|
||||||
|
# Created On: 2006/05/02
|
||||||
|
# $Id$
|
||||||
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
|
|
||||||
|
import cStringIO
|
||||||
|
import xml.dom.minidom
|
||||||
|
|
||||||
|
from nose.tools import eq_
|
||||||
|
|
||||||
|
from ..ignore import *
|
||||||
|
|
||||||
|
def test_empty():
|
||||||
|
il = IgnoreList()
|
||||||
|
eq_(0,len(il))
|
||||||
|
assert not il.AreIgnored('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')
|
||||||
|
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')
|
||||||
|
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')
|
||||||
|
eq_(0,len(il))
|
||||||
|
|
||||||
|
def test_add_same_twice():
|
||||||
|
il = IgnoreList()
|
||||||
|
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')
|
||||||
|
f = cStringIO.StringIO()
|
||||||
|
il.save_to_xml(f)
|
||||||
|
f.seek(0)
|
||||||
|
doc = xml.dom.minidom.parse(f)
|
||||||
|
root = doc.documentElement
|
||||||
|
eq_('ignore_list',root.nodeName)
|
||||||
|
children = [c for c in root.childNodes if c.localName]
|
||||||
|
eq_(2,len(children))
|
||||||
|
eq_(2,len([c for c in children if c.nodeName == 'file']))
|
||||||
|
f1,f2 = children
|
||||||
|
subchildren = [c for c in f1.childNodes if c.localName == 'file'] +\
|
||||||
|
[c for c in f2.childNodes if c.localName == 'file']
|
||||||
|
eq_(3,len(subchildren))
|
||||||
|
|
||||||
|
def test_SaveThenLoad():
|
||||||
|
il = IgnoreList()
|
||||||
|
il.Ignore('foo','bar')
|
||||||
|
il.Ignore('foo','bleh')
|
||||||
|
il.Ignore('bleh','bar')
|
||||||
|
il.Ignore(u'\u00e9','bar')
|
||||||
|
f = cStringIO.StringIO()
|
||||||
|
il.save_to_xml(f)
|
||||||
|
f.seek(0)
|
||||||
|
il = IgnoreList()
|
||||||
|
il.load_from_xml(f)
|
||||||
|
eq_(4,len(il))
|
||||||
|
assert il.AreIgnored(u'\u00e9','bar')
|
||||||
|
|
||||||
|
def test_LoadXML_with_empty_file_tags():
|
||||||
|
f = cStringIO.StringIO()
|
||||||
|
f.write('<?xml version="1.0" encoding="utf-8"?><ignore_list><file><file/></file></ignore_list>')
|
||||||
|
f.seek(0)
|
||||||
|
il = IgnoreList()
|
||||||
|
il.load_from_xml(f)
|
||||||
|
eq_(0,len(il))
|
||||||
|
|
||||||
|
def test_AreIgnore_works_when_a_child_is_a_key_somewhere_else():
|
||||||
|
il = IgnoreList()
|
||||||
|
il.Ignore('foo','bar')
|
||||||
|
il.Ignore('bar','baz')
|
||||||
|
assert il.AreIgnored('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')
|
||||||
|
eq_(2,len(il))
|
||||||
|
|
||||||
|
def test_iterate():
|
||||||
|
#It must be possible to iterate through ignore list
|
||||||
|
il = IgnoreList()
|
||||||
|
expected = [('foo','bar'),('bar','baz'),('foo','baz')]
|
||||||
|
for i in expected:
|
||||||
|
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
|
||||||
|
|
||||||
|
def test_filter():
|
||||||
|
il = IgnoreList()
|
||||||
|
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')
|
||||||
|
|
||||||
|
def test_save_with_non_ascii_non_unicode_items():
|
||||||
|
il = IgnoreList()
|
||||||
|
il.Ignore('\xac','\xbf')
|
||||||
|
f = cStringIO.StringIO()
|
||||||
|
try:
|
||||||
|
il.save_to_xml(f)
|
||||||
|
except Exception as e:
|
||||||
|
raise AssertionError(unicode(e))
|
||||||
|
|
||||||
|
def test_len():
|
||||||
|
il = IgnoreList()
|
||||||
|
eq_(0,len(il))
|
||||||
|
il.Ignore('foo','bar')
|
||||||
|
eq_(1,len(il))
|
||||||
|
|
||||||
|
def test_nonzero():
|
||||||
|
il = IgnoreList()
|
||||||
|
assert not il
|
||||||
|
il.Ignore('foo','bar')
|
||||||
|
assert il
|
@ -1,13 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.results_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.results
|
# Created On: 2006/02/23
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/02/23
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
import unittest
|
||||||
import StringIO
|
import StringIO
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
@ -18,9 +14,8 @@ from hsutil.testcase import TestCase
|
|||||||
from hsutil.misc import first
|
from hsutil.misc import first
|
||||||
|
|
||||||
from . import engine_test
|
from . import engine_test
|
||||||
from . import data
|
from .. import data, engine
|
||||||
from . import engine
|
from ..results import *
|
||||||
from .results import *
|
|
||||||
|
|
||||||
class NamedObject(engine_test.NamedObject):
|
class NamedObject(engine_test.NamedObject):
|
||||||
size = 1
|
size = 1
|
||||||
@ -715,7 +710,7 @@ class TCResultsFilter(TestCase):
|
|||||||
self.assertEqual(expected, self.results.stat_line)
|
self.assertEqual(expected, self.results.stat_line)
|
||||||
|
|
||||||
|
|
||||||
class TCResultsRefFile(unittest.TestCase):
|
class TCResultsRefFile(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.results = Results(data)
|
self.results = Results(data)
|
||||||
self.objects, self.matches, self.groups = GetTestGroups()
|
self.objects, self.matches, self.groups = GetTestGroups()
|
||||||
@ -737,6 +732,3 @@ class TCResultsRefFile(unittest.TestCase):
|
|||||||
expected = '0 / 2 (0.00 B / 2.00 B) duplicates marked.'
|
expected = '0 / 2 (0.00 B / 2.00 B) duplicates marked.'
|
||||||
self.assertEqual(expected, self.results.stat_line)
|
self.assertEqual(expected, self.results.stat_line)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,22 +1,16 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.tests.scanner_test
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.tests.scanner
|
# Created On: 2006/03/03
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/03/03
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4385 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from hsutil import job
|
from hsutil import job
|
||||||
from hsutil.path import Path
|
from hsutil.path import Path
|
||||||
from hsutil.testcase import TestCase
|
from hsutil.testcase import TestCase
|
||||||
|
|
||||||
from .engine import getwords, Match
|
from ..engine import getwords, Match
|
||||||
from .ignore import IgnoreList
|
from ..ignore import IgnoreList
|
||||||
from .scanner import *
|
from ..scanner import *
|
||||||
|
|
||||||
class NamedObject(object):
|
class NamedObject(object):
|
||||||
def __init__(self, name="foobar", size=1):
|
def __init__(self, name="foobar", size=1):
|
||||||
@ -463,6 +457,3 @@ class TCScannerME(TestCase):
|
|||||||
[group] = s.GetDupeGroups([o1, o2])
|
[group] = s.GetDupeGroups([o1, o2])
|
||||||
self.assertTrue(group.ref is o2)
|
self.assertTrue(group.ref is o2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
Loading…
Reference in New Issue
Block a user