summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-07-27 10:20:26 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-07-27 10:20:26 +0200
commitfd15c8efa8b1344aa05ef4531e65df698b1b8679 (patch)
treebc164ed6566acf42e52e188f2542f2525a275db8
parent3e5c562599e14ba1d8af5a69ddb69f1a590ba374 (diff)
downloadlogilab-common-fd15c8efa8b1344aa05ef4531e65df698b1b8679.tar.gz
[cleanup] delete-trailing-whitespaces
-rw-r--r--test/data/module.py12
-rw-r--r--test/data/module2.py4
-rw-r--r--test/data/noendingnewline.py16
-rw-r--r--test/unittest_adbh.py6
-rw-r--r--test/unittest_bind.py5
-rw-r--r--test/unittest_cache.py2
-rw-r--r--test/unittest_changelog.py2
-rw-r--r--test/unittest_compat.py27
-rw-r--r--test/unittest_date.py2
-rw-r--r--test/unittest_db.py24
-rw-r--r--test/unittest_fileutils.py12
-rw-r--r--test/unittest_graph.py8
-rw-r--r--test/unittest_interface.py10
-rw-r--r--test/unittest_patricia.py8
-rw-r--r--test/unittest_shellutils.py6
-rw-r--r--test/unittest_table.py34
-rw-r--r--test/unittest_taskqueue.py14
-rw-r--r--test/unittest_testlib.py109
-rw-r--r--test/unittest_textutils.py32
-rw-r--r--test/unittest_tree.py56
-rw-r--r--test/unittest_umessage.py5
-rw-r--r--test/unittest_ureports_html.py10
-rw-r--r--test/unittest_ureports_text.py8
-rw-r--r--test/utils.py14
-rw-r--r--ureports/__init__.py10
-rw-r--r--ureports/docbook_writer.py22
-rw-r--r--ureports/html_writer.py18
-rw-r--r--ureports/nodes.py34
-rw-r--r--ureports/text_writer.py24
29 files changed, 262 insertions, 272 deletions
diff --git a/test/data/module.py b/test/data/module.py
index 8cadbca..9b85430 100644
--- a/test/data/module.py
+++ b/test/data/module.py
@@ -36,11 +36,11 @@ class YO:
raise XXXError()
except:
raise
-
-#print '*****>',YO.__dict__
+
+#print '*****>',YO.__dict__
class YOUPI(YO):
class_attr = None
-
+
def __init__(self):
self.member = None
@@ -63,12 +63,12 @@ class YOUPI(YO):
"""static method test"""
assert MY_DICT, '???'
static_method = staticmethod(static_method)
-
+
def class_method(cls):
"""class method test"""
exec a in b
class_method = classmethod(class_method)
-
+
def nested_args(a, (b, c, d)):
"""nested arguments test"""
@@ -84,5 +84,5 @@ def nested_args(a, (b, c, d)):
else:
c = a and b or d
map(lambda x, y: (y, x), a)
-
+
redirect = nested_args
diff --git a/test/data/module2.py b/test/data/module2.py
index 3961865..78976c4 100644
--- a/test/data/module2.py
+++ b/test/data/module2.py
@@ -23,7 +23,7 @@ class AbstractClass(object):
if param:
return 'toto'
return
-
+
class Concrete0:
__implements__ = MyIFace
class Concrete1:
@@ -46,7 +46,7 @@ def raise_string(a=2, *args, **kwargs):
raise 'pas glop'
raise Exception, 'yo'
yield 'coucou'
-
+
a = b + 2
c = b * 2
c = b / 2
diff --git a/test/data/noendingnewline.py b/test/data/noendingnewline.py
index 353ded4..703b124 100644
--- a/test/data/noendingnewline.py
+++ b/test/data/noendingnewline.py
@@ -1,17 +1,17 @@
-import unittest
+import unittest
class TestCase(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
-
-
+
+
def tearDown(self):
unittest.TestCase.tearDown(self)
-
+
def testIt(self):
self.a = 10
self.xxx()
@@ -21,11 +21,11 @@ class TestCase(unittest.TestCase):
if False:
pass
print 'a'
-
+
if False:
pass
pass
-
+
if False:
pass
print 'rara'
@@ -33,6 +33,4 @@ class TestCase(unittest.TestCase):
if __name__ == '__main__':
print 'test2'
- unittest.main()
-
- \ No newline at end of file
+ unittest.main()
diff --git a/test/unittest_adbh.py b/test/unittest_adbh.py
index 5c054d2..e9d7ef9 100644
--- a/test/unittest_adbh.py
+++ b/test/unittest_adbh.py
@@ -8,7 +8,7 @@ class PGHelperTC(TestCase):
driver = 'postgres'
def setUp(self):
self.helper = get_adv_func_helper(self.driver)
-
+
def test_type_map(self):
self.assertEquals(self.helper.TYPE_MAPPING['Datetime'], 'timestamp')
self.assertEquals(self.helper.TYPE_MAPPING['String'], 'text')
@@ -22,13 +22,13 @@ class SQLITEHelperTC(PGHelperTC):
class MYHelperTC(PGHelperTC):
driver = 'mysql'
-
+
def test_type_map(self):
self.assertEquals(self.helper.TYPE_MAPPING['Datetime'], 'datetime')
self.assertEquals(self.helper.TYPE_MAPPING['String'], 'mediumtext')
self.assertEquals(self.helper.TYPE_MAPPING['Password'], 'tinyblob')
self.assertEquals(self.helper.TYPE_MAPPING['Bytes'], 'longblob')
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_bind.py b/test/unittest_bind.py
index 0c3e2a3..282577b 100644
--- a/test/unittest_bind.py
+++ b/test/unittest_bind.py
@@ -45,7 +45,7 @@ class BindTC(TestCase):
consts_dict, consts_list)
self.assertEquals(consts_list, [None, 'hacked !'])
self.assertEquals(modified, ['HELLO'])
-
+
def test_optimize_module2(self):
"""test optimize_module_2()"""
f1_consts = Set(foomod.f1.func_code.co_consts)
@@ -57,7 +57,6 @@ class BindTC(TestCase):
newf3_consts = Set(foomod.f3.func_code.co_consts)
self.assert_(newf1_consts == newf2_consts == newf3_consts)
self.assertEquals(newf1_consts, f1_consts | f2_consts | f3_consts)
-
+
if __name__ == '__main__':
unittest_main()
-
diff --git a/test/unittest_cache.py b/test/unittest_cache.py
index ae96610..708c30c 100644
--- a/test/unittest_cache.py
+++ b/test/unittest_cache.py
@@ -96,7 +96,7 @@ class CacheTestCase(TestCase):
self.assertRaises(KeyError, null_cache.__getitem__, 'foo')
# Deleting element raises a KeyError
self.assertRaises(KeyError, null_cache.__delitem__, 'foo')
-
+
def test_getitem(self):
""" Checks that getitem doest not modify the _usage attribute
"""
diff --git a/test/unittest_changelog.py b/test/unittest_changelog.py
index 7f9262f..1c31d8b 100644
--- a/test/unittest_changelog.py
+++ b/test/unittest_changelog.py
@@ -14,7 +14,7 @@ class ChangeLogTC(TestCase):
out = StringIO()
cl.write(out)
self.assertStreamEquals(open(self.cl_file), out)
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_compat.py b/test/unittest_compat.py
index eaa769b..a7a4f53 100644
--- a/test/unittest_compat.py
+++ b/test/unittest_compat.py
@@ -10,14 +10,14 @@ class CompatTCMixIn:
MODNAMES = {}
BUILTINS = []
ALTERED_BUILTINS = {}
-
+
def setUp(self):
self.builtins_backup = {}
self.modules_backup = {}
self.remove_builtins()
self.alter_builtins()
self.remove_modules()
-
+
def tearDown(self):
for modname in self.MODNAMES:
del sys.modules[modname]
@@ -30,7 +30,7 @@ class CompatTCMixIn:
del sys.modules['logilab.common.compat']
except KeyError:
pass
-
+
def remove_builtins(self):
for builtin in self.BUILTINS:
func = getattr(__builtin__, builtin, None)
@@ -45,13 +45,13 @@ class CompatTCMixIn:
self.builtins_backup[builtin] = old_func
setattr(__builtin__, builtin, func)
# setattr(__builtin__, 'builtin_%s' % builtin, func)
-
+
def remove_modules(self):
for modname in self.MODNAMES:
if modname in sys.modules:
self.modules_backup[modname] = sys.modules[modname]
sys.modules[modname] = types.ModuleType('faked%s' % modname)
-
+
def test_removed_builtins(self):
"""tests that builtins are actually uncallable"""
for builtin in self.BUILTINS:
@@ -77,7 +77,7 @@ class Py23CompatTC(CompatTCMixIn, TestCase):
from logilab.common.compat import sum
self.assertEquals(sum(range(5)), 10)
self.assertRaises(TypeError, sum, 'abc')
-
+
def test_enumerate(self):
from logilab.common.compat import enumerate
self.assertEquals(list(enumerate([])), [])
@@ -120,11 +120,11 @@ class Py23CompatTC(CompatTCMixIn, TestCase):
d[s] = 'bar'
self.assertEquals(len(d), 1)
self.assertEquals(d[s], 'bar')
-
+
class Py24CompatTC(CompatTCMixIn, TestCase):
BUILTINS = ('reversed', 'sorted', 'set', 'frozenset',)
-
+
def test_sorted(self):
from logilab.common.compat import sorted
l = [3, 1, 2, 5, 4]
@@ -145,7 +145,7 @@ class Py24CompatTC(CompatTCMixIn, TestCase):
r = reversed(l)
self.assertEquals(r, [4, 3, 2, 1, 0])
self.assertEquals(l, range(5))
-
+
def test_set(self):
from logilab.common.compat import set
s1 = set(range(5))
@@ -163,7 +163,7 @@ class _MaxFaker(object):
if kargs:
raise TypeError("max() takes no keyword argument")
return self.func(*args)
-
+
class Py25CompatTC(CompatTCMixIn, TestCase):
BUILTINS = ('any', 'all',)
@@ -178,7 +178,7 @@ class Py25CompatTC(CompatTCMixIn, TestCase):
self.assertEquals(any('abc'), True)
self.assertEquals(any(xrange(10)), True)
self.assertEquals(any(xrange(0, -10, -1)), True)
- # python2.5's any consumes iterables
+ # python2.5's any consumes iterables
irange = iter(range(10))
self.assertEquals(any(irange), True)
self.assertEquals(irange.next(), 2)
@@ -193,14 +193,14 @@ class Py25CompatTC(CompatTCMixIn, TestCase):
self.assertEquals(all('abc'), True)
self.assertEquals(all(xrange(10)), False)
self.assertEquals(all(xrange(0, -10, -1)), False)
- # python2.5's all consumes iterables
+ # python2.5's all consumes iterables
irange = iter(range(10))
self.assertEquals(all(irange), False)
self.assertEquals(irange.next(), 1)
def test_max(self):
from logilab.common.compat import max
-
+
# old apy
self.assertEquals(max("fdjkmhsgmdfhsg"),'s')
self.assertEquals(max(1,43,12,45,1337,34,2), 1337)
@@ -220,4 +220,3 @@ class Py25CompatTC(CompatTCMixIn, TestCase):
if __name__ == '__main__':
unittest_main()
-
diff --git a/test/unittest_date.py b/test/unittest_date.py
index 78f3151..9c2c21f 100644
--- a/test/unittest_date.py
+++ b/test/unittest_date.py
@@ -40,7 +40,7 @@ class DateTC(TestCase):
self.assertEquals(add(self.datecls(2008, 1, 3), 8), self.datecls(2008, 1, 15))
# skip holiday + week-end
self.assertEquals(add(self.datecls(2008, 4, 30), 2), self.datecls(2008, 5, 5))
-
+
def test_get_national_holidays(self):
holidays = get_national_holidays
yield self.assertEquals, holidays(self.datecls(2008, 4, 29), self.datecls(2008, 5, 2)), \
diff --git a/test/unittest_db.py b/test/unittest_db.py
index ce05c8c..8b7ec78 100644
--- a/test/unittest_db.py
+++ b/test/unittest_db.py
@@ -17,11 +17,11 @@ class PreferedDriverTC(TestCase):
def setUp(self):
self.drivers = {"pg":[('foo', None), ('bar', None)]}
self.drivers = {'pg' : ["foo", "bar"]}
-
+
def testNormal(self):
set_prefered_driver('pg','bar', self.drivers)
self.assertEquals('bar', self.drivers['pg'][0])
-
+
def testFailuresDb(self):
try:
set_prefered_driver('oracle','bar', self.drivers)
@@ -58,7 +58,7 @@ class GetCnxTC(TestCase):
self.db = 'template1'
self.user = 'adim'
self.passwd = 'adim'
-
+
def testPsyco(self):
set_prefered_driver('postgres', 'psycopg')
try:
@@ -114,7 +114,7 @@ class GetCnxTC(TestCase):
quiet=1, pywrap = True)
self.failUnless(isinstance(cnx, PyConnection),
'cnx should be a PyConnection instance')
-
+
def test_cursor_wrap(self):
"""Tests cursor wrapping"""
@@ -151,7 +151,7 @@ class DBAPIAdaptersTC(TestCase):
def test_raise(self):
self.assertRaises(UnknownDriver, get_dbapi_compliant_module, 'pougloup')
-
+
def test_pgdb_types(self):
"""Tests that NUMBER really wraps all number types"""
PREFERED_DRIVERS['postgres'] = ['pgdb']
@@ -160,8 +160,8 @@ class DBAPIAdaptersTC(TestCase):
module = get_dbapi_compliant_module('postgres')
except ImportError:
self.skip('postgresql pgdb module not installed')
- number_types = ('int2', 'int4', 'serial',
- 'int8', 'float4', 'float8',
+ number_types = ('int2', 'int4', 'serial',
+ 'int8', 'float4', 'float8',
'numeric', 'bool', 'money', 'decimal')
for num_type in number_types:
yield self.assertEquals, num_type, module.NUMBER
@@ -173,23 +173,23 @@ class DBAPIAdaptersTC(TestCase):
try:
module = get_dbapi_compliant_module('postgres')
except ImportError:
- self.skip('postgresql dbapi module not installed')
+ self.skip('postgresql dbapi module not installed')
try:
binary = module.BINARY
except AttributeError, err:
raise
- self.fail(str(err))
+ self.fail(str(err))
def test_adv_func_helper(self):
try:
module = get_dbapi_compliant_module('postgres')
except ImportError:
- self.skip('postgresql dbapi module not installed')
+ self.skip('postgresql dbapi module not installed')
self.failUnless(isinstance(module.adv_func_helper, _PGAdvFuncHelper))
try:
module = get_dbapi_compliant_module('sqlite')
except ImportError:
- self.skip('sqlite dbapi module not installed')
+ self.skip('sqlite dbapi module not installed')
self.failUnless(isinstance(module.adv_func_helper, _SqliteAdvFuncHelper))
@@ -223,7 +223,7 @@ class DBAPIAdaptersTC(TestCase):
self.assertEquals(pghelper.func_sqlname('MYFUNC'), 'MYFUNC')
self.assertEquals(mshelper.func_sqlname('MYFUNC'), 'MYF')
self.assertEquals(slhelper.func_sqlname('MYFUNC'), 'SQLITE_MYFUNC')
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_fileutils.py b/test/unittest_fileutils.py
index 25cd9d4..f46d8e0 100644
--- a/test/unittest_fileutils.py
+++ b/test/unittest_fileutils.py
@@ -17,7 +17,7 @@ class FirstleveldirectoryTC(TestCase):
"""return the first level directory of a path"""
self.assertEqual(first_level_directory('truc/bidule/chouette'), 'truc', None)
self.assertEqual(first_level_directory('/truc/bidule/chouette'), '/', None)
-
+
class IsBinaryTC(TestCase):
def test(self):
self.assertEqual(is_binary('toto.txt'), 0)
@@ -25,7 +25,7 @@ class IsBinaryTC(TestCase):
self.assertEqual(is_binary('toto.bin'), 1)
self.assertEqual(is_binary('toto.sxi'), 1)
self.assertEqual(is_binary('toto.whatever'), 1)
-
+
class GetModeTC(TestCase):
def test(self):
self.assertEqual(write_open_mode('toto.txt'), 'w')
@@ -43,7 +43,7 @@ class LinesTC(TestCase):
def test_known_values_lines(self):
self.assertEqual(lines(NEWLINES_TXT),
['# mixed new lines', '1', '2', '3'])
-
+
def test_known_values_lines_comment(self):
self.assertEqual(lines(NEWLINES_TXT, comments='#'),
['1', '2', '3'])
@@ -59,7 +59,7 @@ class ExportTC(TestCase):
self.assert_(exists(join(self.tempdir, 'sub')))
self.assert_(not exists(join(self.tempdir, '__init__.pyc')))
self.assert_(not exists(join(self.tempdir, 'CVS')))
-
+
def tearDown(self):
shutil.rmtree(self.tempdir)
@@ -101,7 +101,7 @@ class ProtectedFileTC(TestCase):
self.assert_(os.access(self.rpath, os.W_OK))
wp_file.close()
self.assert_(not os.access(self.rpath, os.W_OK))
-
+
from logilab.common.testlib import DocTest
class ModuleDocTest(DocTest):
@@ -109,7 +109,7 @@ class ModuleDocTest(DocTest):
from logilab.common import fileutils as module
skipped = ('abspath_listdir',)
-
+
del DocTest # necessary if we don't want it to be executed (we don't...)
if __name__ == '__main__':
diff --git a/test/unittest_graph.py b/test/unittest_graph.py
index 07c519c..b8f5394 100644
--- a/test/unittest_graph.py
+++ b/test/unittest_graph.py
@@ -7,15 +7,13 @@ class getCycleTestCase(TestCase):
def test_known0(self):
self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1]}), [[1, 2, 3]])
-
+
def test_known1(self):
self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1, 4], 4:[3]}), [[1, 2, 3], [3, 4]])
-
+
def test_known2(self):
self.assertEqual(get_cycles({1:[2], 2:[3], 3:[0], 0:[]}), [])
-
+
if __name__ == "__main__":
unittest_main()
-
-
diff --git a/test/unittest_interface.py b/test/unittest_interface.py
index e38e6b1..b16642a 100644
--- a/test/unittest_interface.py
+++ b/test/unittest_interface.py
@@ -15,10 +15,10 @@ class B(A): pass
class C1(B):
__implements__ = list(B.__implements__) + [IFace3]
-
+
class C2(B):
__implements__ = B.__implements__ + (IFace2,)
-
+
class D(C1):
__implements__ = ()
@@ -32,10 +32,10 @@ class ExtendTC(TestCase):
c1impl = C1.__implements__
c2impl = C2.__implements__
dimpl = D.__implements__
-
+
def test_base(self):
extend(A, IFace2)
- self.failUnlessEqual(A.__implements__, (IFace1, IFace2))
+ self.failUnlessEqual(A.__implements__, (IFace1, IFace2))
self.failUnlessEqual(B.__implements__, (IFace1, IFace2))
self.failUnless(B.__implements__ is A.__implements__)
self.failUnlessEqual(C1.__implements__, [IFace1, IFace3, IFace2])
@@ -50,7 +50,7 @@ class ExtendTC(TestCase):
def test_no_impl(self):
extend(Z, IFace1)
self.failUnlessEqual(Z.__implements__, (IFace1,))
-
+
def test_notimpl_explicit(self):
extend(C1, IFace3)
self.failUnless(C1.__implements__ is c1impl)
diff --git a/test/unittest_patricia.py b/test/unittest_patricia.py
index 5c000ae..fad1078 100644
--- a/test/unittest_patricia.py
+++ b/test/unittest_patricia.py
@@ -6,11 +6,11 @@ __revision__ = "$Id: unittest_patricia.py,v 1.3 2003-09-05 10:22:35 syt Exp $"
from logilab.common.patricia import *
from logilab.common.testlib import TestCase, unittest_main
-
+
class PatriciaTrieClassTest(TestCase):
-
+
def test_knownValues(self):
- """
+ """
remove a child node
"""
p = PatriciaTrie()
@@ -50,7 +50,7 @@ class PatriciaTrieClassTest(TestCase):
except KeyError:
pass
#print p
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py
index 17bc0e0..e0ba67f 100644
--- a/test/unittest_shellutils.py
+++ b/test/unittest_shellutils.py
@@ -24,7 +24,7 @@ class FindTC(TestCase):
set([join(DATA_DIR, f) for f in ['__init__.py', 'module.py',
'module2.py', 'noendingnewline.py',
'nonregr.py']]))
-
+
def test_exclude(self):
files = set(find(DATA_DIR, ('.py', '.pyc'), exclude=True))
self.assertSetEqual(files,
@@ -71,7 +71,7 @@ class ProgressBarTC(TestCase):
pgb.refresh()
expected_stream.write("\r["+' '*35+"]")
self.assertEquals(pgb_stream.getvalue(), expected_stream.getvalue())
-
+
def test_refresh_l_size(self):
pgb_stream = StringIO()
expected_stream = StringIO()
@@ -79,7 +79,7 @@ class ProgressBarTC(TestCase):
pgb.refresh()
expected_stream.write("\r["+' '*3+"]")
self.assertEquals(pgb_stream.getvalue(), expected_stream.getvalue())
-
+
def _update_test(self, nbops, expected, size = None):
pgb_stream = StringIO()
expected_stream = StringIO()
diff --git a/test/unittest_table.py b/test/unittest_table.py
index d41c646..1ce0fc7 100644
--- a/test/unittest_table.py
+++ b/test/unittest_table.py
@@ -46,7 +46,7 @@ class TableTC(TestCase):
tab.append_row([2])
self.assertEquals(tab, [[1],[2]])
self.assertEquals(tab[:,0], [1,2])
-
+
def test_indexation(self):
"""we should be able to use [] to access rows"""
self.assert_(self.table[0] == self.table.data[0])
@@ -65,7 +65,7 @@ class TableTC(TestCase):
self.table.insert_column(1, range(3), 'supp')
self.assertEquals(self.table, [[0, 0, 0], [0, 1, 0], [0, 2, 0]])
self.assertEquals(self.table[:], [[0, 0, 0], [0, 1, 0], [0, 2, 0]])
-
+
def test_get_cells(self):
self.table.insert_column(1, range(3), 'supp')
self.assertEquals(self.table[0,1], 0)
@@ -76,13 +76,13 @@ class TableTC(TestCase):
self.assertEquals(self.table['row3', 'supp'], 2)
self.assertRaises(KeyError, self.table.__getitem__, ('row1', 'foo'))
self.assertRaises(KeyError, self.table.__getitem__, ('foo', 'bar'))
-
+
def test_shape(self):
"""tests table shape"""
self.assertEquals(self.table.shape, (3, 2))
self.table.insert_column(1, range(3), 'supp')
self.assertEquals(self.table.shape, (3, 3))
-
+
def test_set_column(self):
"""Tests that table.set_column() works fine.
"""
@@ -121,7 +121,7 @@ class TableTC(TestCase):
self.assertRaises(KeyError, self.table.delete_row_by_id, 'tmprow')
self.assertEquals(self.table[1], [0, 0])
self.assertRaises(KeyError, self.table.__getitem__, 'tmprow')
-
+
def test_get_column(self):
"""Tests that table.get_column() works fine.
"""
@@ -136,7 +136,7 @@ class TableTC(TestCase):
self.table.set_cell(0, 1, 12)
self.table.set_cell(2, 1, 13)
self.assertEquals(self.table.get_columns(), [[0,0,0], [12,0,13]])
-
+
def test_insert_column(self):
"""Tests that table.insert_column() works fine.
"""
@@ -175,7 +175,7 @@ class TableTC(TestCase):
self.table.sort_by_column_index(1, 'desc')
self.assertEquals(self.table.row_names, ['row3', 'row2', 'row1'])
self.assertEquals(self.table.data, [[2, 3], [1, 2], [3, 1]])
-
+
def test_sort_by_id(self):
"""tests sort_by_column_id()"""
self.table.set_column_by_id('col1', [3, 1, 2])
@@ -204,7 +204,7 @@ class GroupByTC(TestCase):
t.append_row(['date2', 'ing3', 'task3', 0.3])
t.append_row(['date3', 'ing4', 'task2', 0.3])
t.append_row(['date1', 'ing1', 'task3', 0.3])
- t.append_row(['date3', 'ing1', 'task3', 0.3])
+ t.append_row(['date3', 'ing1', 'task3', 0.3])
self.table = t
def test_single_groupby(self):
@@ -264,7 +264,7 @@ class TableStyleSheetTC(TestCase):
def tearDown(self):
sys.stdout = self.stdout_backup
-
+
def test_add_rule(self):
"""Tests that the regex pattern works as expected.
"""
@@ -284,7 +284,7 @@ class TableStyleSheetTC(TestCase):
sheet = TableStyleSheet([rule, 'bad rule'])
self.assertEquals(len(sheet.rules), 1, "Ill-formed rule mustn't be added")
self.assertEquals(len(sheet.instructions), 1, "Ill-formed rule mustn't be added")
-
+
def test_rowavg_rule(self):
"""Tests that add_rowavg_rule works as expected
"""
@@ -293,7 +293,7 @@ class TableStyleSheetTC(TestCase):
self.table.apply_stylesheet(self.stylesheet)
val = self.table[0,2]
self.assert_(int(val) == 15)
-
+
def test_rowsum_rule(self):
"""Tests that add_rowsum_rule works as expected
@@ -303,7 +303,7 @@ class TableStyleSheetTC(TestCase):
self.table.apply_stylesheet(self.stylesheet)
val = self.table[0,2]
self.assert_(val == 30)
-
+
def test_colavg_rule(self):
"""Tests that add_colavg_rule works as expected
@@ -315,7 +315,7 @@ class TableStyleSheetTC(TestCase):
self.table.apply_stylesheet(self.stylesheet)
val = self.table[2,0]
self.assert_(int(val) == 11)
-
+
def test_colsum_rule(self):
"""Tests that add_colsum_rule works as expected
@@ -366,7 +366,7 @@ class TableStyleTC(TestCase):
isetter('FOO', 1)
self.assertEquals(getter('col1'), 'FOO')
self.assertEquals(igetter(1), 'FOO')
-
+
class RendererTC(TestCase):
"""Test suite for DocbookRenderer"""
@@ -377,7 +377,7 @@ class RendererTC(TestCase):
self.table.create_columns(['col1', 'col2'])
self.style = TableStyle(self.table)
self.base_renderer = TableCellRenderer()
-
+
def test_cell_content(self):
"""test how alignment is rendered"""
entry_xml = self.renderer._render_cell_content('data', self.style, 1)
@@ -425,7 +425,7 @@ class DocbookTableWriterTC(TestCase):
"""tests that Abstract Writers can't be used !"""
writer = TableWriter(self.stream, self.table, None)
self.assertRaises(NotImplementedError, writer.write_table)
-
-
+
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_taskqueue.py b/test/unittest_taskqueue.py
index a723d1c..80b00ad 100644
--- a/test/unittest_taskqueue.py
+++ b/test/unittest_taskqueue.py
@@ -3,20 +3,20 @@ from logilab.common.testlib import TestCase, unittest_main
from logilab.common.tasksqueue import *
class TaskTC(TestCase):
-
+
def test_eq(self):
self.failIf(Task('t1') == Task('t2'))
self.failUnless(Task('t1') == Task('t1'))
-
+
def test_cmp(self):
self.failUnless(Task('t1', LOW) < Task('t2', MEDIUM))
self.failIf(Task('t1', LOW) > Task('t2', MEDIUM))
self.failUnless(Task('t1', HIGH) > Task('t2', MEDIUM))
self.failIf(Task('t1', HIGH) < Task('t2', MEDIUM))
-
+
class PrioritizedTasksQueueTC(TestCase):
-
+
def test_priority(self):
queue = PrioritizedTasksQueue()
queue.put(Task('t1'))
@@ -27,7 +27,7 @@ class PrioritizedTasksQueueTC(TestCase):
self.assertEquals(queue.get().id, 't2')
self.assertEquals(queue.get().id, 't1')
self.assertEquals(queue.get().id, 't4')
-
+
def test_remove_equivalent(self):
queue = PrioritizedTasksQueue()
queue.put(Task('t1'))
@@ -40,7 +40,7 @@ class PrioritizedTasksQueueTC(TestCase):
self.assertEquals(queue.get().id, 't2')
self.assertEquals(queue.get().id, 't3')
self.assertEquals(queue.qsize(), 0)
-
+
def test_remove(self):
queue = PrioritizedTasksQueue()
queue.put(Task('t1'))
@@ -49,6 +49,6 @@ class PrioritizedTasksQueueTC(TestCase):
queue.remove('t2')
self.assertEquals([t.id for t in queue], ['t3', 't1'])
self.assertRaises(ValueError, queue.remove, 't4')
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py
index 053ae05..b1ec568 100644
--- a/test/unittest_testlib.py
+++ b/test/unittest_testlib.py
@@ -16,7 +16,7 @@ try:
__file__
except NameError:
__file__ = sys.argv[0]
-
+
from unittest import TestSuite
@@ -64,12 +64,12 @@ class UtilTC(TestCase):
self.assertEquals(dircontent('a/b/c/d'), ['e.py'])
finally:
shutil.rmtree(chroot)
-
+
class TestlibTC(TestCase):
capture = True
-
+
def mkdir(self,path):
if not exists(path):
self._dirs.add(path)
@@ -109,7 +109,7 @@ class TestlibTC(TestCase):
text
"""
t2 = """some
-
+
text"""
t3 = """some
text"""
@@ -161,13 +161,13 @@ class TestlibTC(TestCase):
self.assertRaises(AssertionError, self.tc.assertSetEquals, s1, s2)
self.tc.assertSetEquals(s1, s1)
self.tc.assertSetEquals(set(), set())
-
+
def test_file_equality(self):
foo = join(dirname(__file__), 'data', 'foo.txt')
- spam = join(dirname(__file__), 'data', 'spam.txt')
+ spam = join(dirname(__file__), 'data', 'spam.txt')
self.assertRaises(AssertionError, self.tc.assertFileEqual, foo, spam)
self.tc.assertFileEqual(foo, foo)
-
+
def test_dir_equality(self):
ref = join(dirname(__file__), 'data', 'reference_dir')
same = join(dirname(__file__), 'data', 'same_dir')
@@ -188,24 +188,24 @@ class TestlibTC(TestCase):
self.assertRaises(AssertionError, self.assertDirEquals, subdir_differ, ref)
self.assertRaises(AssertionError, self.assertDirEquals, file_differ, ref)
self.assertRaises(AssertionError, self.assertDirEquals, ref, content_differ)
-
+
def test_stream_equality(self):
foo = join(dirname(__file__), 'data', 'foo.txt')
- spam = join(dirname(__file__), 'data', 'spam.txt')
+ spam = join(dirname(__file__), 'data', 'spam.txt')
stream1 = file(foo)
self.tc.assertStreamEqual(stream1, stream1)
stream1 = file(foo)
stream2 = file(spam)
self.assertRaises(AssertionError, self.tc.assertStreamEqual, stream1, stream2)
-
+
def test_text_equality(self):
self.assertRaises(AssertionError, self.tc.assertTextEqual, "toto", 12)
self.assertRaises(AssertionError, self.tc.assertTextEqual, "toto", None)
self.assertRaises(AssertionError, self.tc.assertTextEqual, 3.12, u"toto")
self.assertRaises(AssertionError, self.tc.assertTextEqual, None, u"toto")
-
+
foo = join(dirname(__file__), 'data', 'foo.txt')
- spam = join(dirname(__file__), 'data', 'spam.txt')
+ spam = join(dirname(__file__), 'data', 'spam.txt')
text1 = file(foo).read()
self.tc.assertTextEqual(text1, text1)
text2 = file(spam).read()
@@ -216,7 +216,7 @@ class TestlibTC(TestCase):
exc = self.tc.assertRaises(KeyError, {}.__getitem__, 'foo')
self.failUnless(isinstance(exc, KeyError))
self.assertEquals(exc.args, ('foo',))
-
+
def test_default_datadir(self):
expected_datadir = join(dirname(abspath(__file__)), 'data')
@@ -233,14 +233,14 @@ class TestlibTC(TestCase):
self.assertEquals(tc.datapath('bar'), join('foo', 'bar'))
# instance's custom datadir
tc.datadir = 'spam'
- self.assertEquals(tc.datapath('bar'), join('spam', 'bar'))
+ self.assertEquals(tc.datapath('bar'), join('spam', 'bar'))
def test_cached_datadir(self):
"""test datadir is cached on the class"""
class MyTC(TestCase):
def test_1(self): pass
-
+
expected_datadir = join(dirname(abspath(__file__)), 'data')
tc = MyTC('test_1')
self.assertEquals(tc.datadir, expected_datadir)
@@ -250,13 +250,13 @@ class TestlibTC(TestCase):
# even on new instances
tc2 = MyTC('test_1')
self.assertEquals(tc2.datadir, expected_datadir)
-
+
def test_is(self):
obj_1 = []
obj_2 = []
self.assertIs(obj_1,obj_1)
self.assertRaises(AssertionError, self.assertIs, obj_1, obj_2)
-
+
def test_isnot(self):
obj_1 = []
obj_2 = []
@@ -282,7 +282,7 @@ class TestlibTC(TestCase):
class GenerativeTestsTC(TestCase):
-
+
def setUp(self):
output = StringIO()
self.runner = SkipAwareTextTestRunner(stream=output)
@@ -316,7 +316,7 @@ class GenerativeTestsTC(TestCase):
if i == 5:
raise ValueError('STOP !')
yield self.assertEquals, i, i
-
+
result = self.runner.run(FooTC('test_generative'))
self.assertEquals(result.testsRun, 5)
self.assertEquals(len(result.failures), 0)
@@ -344,7 +344,7 @@ class GenerativeTestsTC(TestCase):
def test_generative(self):
for i in xrange(10):
yield self.assertEquals, i, i
-
+
result = self.runner.run(FooTC('test_generative'))
self.assertEquals(result.testsRun, 1)
self.assertEquals(len(result.failures), 0)
@@ -366,7 +366,7 @@ class ExitFirstTC(TestCase):
self.assertEquals(result.testsRun, 2)
self.assertEquals(len(result.failures), 1)
self.assertEquals(len(result.errors), 0)
-
+
def test_error_exit_first(self):
class FooTC(TestCase):
@@ -378,7 +378,7 @@ class ExitFirstTC(TestCase):
self.assertEquals(result.testsRun, 2)
self.assertEquals(len(result.failures), 0)
self.assertEquals(len(result.errors), 1)
-
+
def test_generative_exit_first(self):
class FooTC(TestCase):
def test_generative(self):
@@ -406,7 +406,7 @@ class TestLoaderTC(TestCase):
self.module = TestLoaderTC # mock_object(FooTC=TestLoaderTC.FooTC, BarTC=TestLoaderTC.BarTC)
self.output = StringIO()
self.runner = SkipAwareTextTestRunner(stream=self.output)
-
+
def assertRunCount(self, pattern, module, expected_count, skipped=()):
if pattern:
suite = self.loader.loadTestsFromNames([pattern], module)
@@ -418,7 +418,7 @@ class TestLoaderTC(TestCase):
self.runner.test_pattern = None
self.runner.skipped_patterns = ()
self.assertEquals(result.testsRun, expected_count)
-
+
def test_collect_everything(self):
"""make sure we don't change the default behaviour
for loadTestsFromModule() and loadTestsFromTestCase
@@ -438,7 +438,7 @@ class TestLoaderTC(TestCase):
]
for pattern, expected_count in data:
yield self.assertRunCount, pattern, self.module, expected_count
-
+
def test_collect_with_pattern(self):
data = [('test_foo1', 1), ('test_foo', 2), ('test_bar', 2),
('foo1', 1), ('foo', 2), ('bar', 2), ('ba', 2),
@@ -464,20 +464,20 @@ class TestLoaderTC(TestCase):
]
for pattern, expected_count in data:
yield self.assertRunCount, pattern, MyMod, expected_count
-
-
+
+
def test_collect_everything_and_skipped_patterns(self):
testdata = [ (['foo1'], 3), (['foo'], 2),
(['foo', 'bar'], 0),
]
for skipped, expected_count in testdata:
yield self.assertRunCount, None, self.module, expected_count, skipped
-
+
def test_collect_specific_pattern_and_skip_some(self):
testdata = [ ('bar', ['foo1'], 2), ('bar', [], 2),
('bar', ['bar'], 0), ]
-
+
for runpattern, skipped, expected_count in testdata:
yield self.assertRunCount, runpattern, self.module, expected_count, skipped
@@ -507,7 +507,7 @@ class TestLoaderTC(TestCase):
else:
yield InnerTest('odd', lambda: None)
yield lambda: None
-
+
data = [('foo', 7), ('test_foobar', 6), ('even', 3), ('odd', 2),
]
for pattern, expected_count in data:
@@ -533,7 +533,7 @@ class TestLoaderTC(TestCase):
class MyTestCase(_Base):
def test_2(self): pass
self.assertRunCount(None, MyMod, 2)
-
+
def bootstrap_print(msg, output=sys.stdout):
"""sys.stdout will be evaluated at function parsing time"""
@@ -541,7 +541,7 @@ def bootstrap_print(msg, output=sys.stdout):
output.write(msg)
class OutErrCaptureTC(TestCase):
-
+
def setUp(self):
sys.stdout = sys.stderr = StringIO()
self.runner = SkipAwareTextTestRunner(stream=StringIO(), exitfirst=True, capture=True)
@@ -559,8 +559,8 @@ class OutErrCaptureTC(TestCase):
result = self.runner.run(test)
captured_out, captured_err = test.captured_output()
self.assertEqual(captured_out.strip(), "foo")
- self.assertEqual(captured_err.strip(), "")
-
+ self.assertEqual(captured_err.strip(), "")
+
def test_stderr_capture(self):
class FooTC(TestCase):
def test_stderr(self):
@@ -570,9 +570,9 @@ class OutErrCaptureTC(TestCase):
result = self.runner.run(test)
captured_out, captured_err = test.captured_output()
self.assertEqual(captured_out.strip(), "")
- self.assertEqual(captured_err.strip(), "foo")
-
-
+ self.assertEqual(captured_err.strip(), "foo")
+
+
def test_both_capture(self):
class FooTC(TestCase):
def test_stderr(self):
@@ -583,8 +583,8 @@ class OutErrCaptureTC(TestCase):
result = self.runner.run(test)
captured_out, captured_err = test.captured_output()
self.assertEqual(captured_out.strip(), "bar")
- self.assertEqual(captured_err.strip(), "foo")
-
+ self.assertEqual(captured_err.strip(), "foo")
+
def test_no_capture(self):
class FooTC(TestCase):
def test_stderr(self):
@@ -597,8 +597,8 @@ class OutErrCaptureTC(TestCase):
result = runner.run(test)
captured_out, captured_err = test.captured_output()
self.assertEqual(captured_out.strip(), "")
- self.assertEqual(captured_err.strip(), "")
-
+ self.assertEqual(captured_err.strip(), "")
+
def test_capture_core(self):
# output = capture_stdout()
@@ -607,7 +607,7 @@ class OutErrCaptureTC(TestCase):
output = capture_stdout()
bootstrap_print("hello")
self.assertEquals(output.restore(), "hello")
-
+
def test_unicode_non_ascii_messages(self):
class FooTC(TestCase):
def test_xxx(self):
@@ -615,7 +615,7 @@ class OutErrCaptureTC(TestCase):
test = FooTC('test_xxx')
# run the test and make sure testlib doesn't raise an exception
result = self.runner.run(test)
-
+
def test_encoded_non_ascii_messages(self):
class FooTC(TestCase):
def test_xxx(self):
@@ -626,7 +626,7 @@ class OutErrCaptureTC(TestCase):
class DecoratorTC(TestCase):
-
+
@with_tempdir
def test_tmp_dir_normal(self):
@@ -650,9 +650,9 @@ class DecoratorTC(TestCase):
self.assertFalse(witness)
createfile(witness)
self.assertTrue(witness)
-
+
self.assertEquals(tempfile.gettempdir(), tempdir)
-
+
# assert temp directory is empty
self.assertListEquals(list(os.walk(tempdir)),
[(tempdir,[],[])])
@@ -679,7 +679,7 @@ class DecoratorTC(TestCase):
raise WitnessException()
self.assertRaises(WitnessException, createfile)
-
+
# assert tempdir didn't change
self.assertEquals(tempfile.gettempdir(), tempdir)
@@ -703,10 +703,10 @@ class DecoratorTC(TestCase):
sys.version_info = (2, 5, 5, 'final', 4)
current = sys.version_info[:3]
compare = ('2.4', '2.5', '2.5.4', '2.5.5')
- for version in compare:
+ for version in compare:
decorator = require_version(version)
self.assertEquals(func, decorator(func), '%s =< %s : function \
- return by the decorator should be the same.' % (version,
+ return by the decorator should be the same.' % (version,
'.'.join([str(element) for element in current])))
def test_require_version_bad(self):
@@ -717,10 +717,10 @@ class DecoratorTC(TestCase):
sys.version_info = (2, 5, 5, 'final', 4)
current = sys.version_info[:3]
compare = ('2.5.6', '2.6', '2.6.5')
- for version in compare:
+ for version in compare:
decorator = require_version(version)
self.assertNotEquals(func, decorator(func), '%s >= %s : function \
- return by the decorator should NOT be the same.'
+ return by the decorator should NOT be the same.'
% ('.'.join([str(element) for element in current]), version))
def test_require_version_exception(self):
@@ -729,7 +729,7 @@ class DecoratorTC(TestCase):
def func() :
pass
compare = ('2.5.a', '2.a', 'azerty')
- for version in compare:
+ for version in compare:
decorator = require_version(version)
self.assertRaises(ValueError, decorator, func)
@@ -759,7 +759,7 @@ class DecoratorTC(TestCase):
not exist : function return by the decorator should \
NOT be the same.' % module)
return
- print 'all modules in %s exist. Could not test %s' % (', '.join(modules),
+ print 'all modules in %s exist. Could not test %s' % (', '.join(modules),
sys._getframe().f_code.co_name)
class TagTC(TestCase):
@@ -773,7 +773,7 @@ class TagTC(TestCase):
def test_tag_decorator(self):
bob = self.func
-
+
self.assertEquals(bob(2, 3, 7), 35)
self.assertTrue(hasattr(bob, 'tags'))
self.assertSetEquals(bob.tags, set(['testing','bob']))
@@ -801,4 +801,3 @@ class TagTC(TestCase):
if __name__ == '__main__':
unittest_main()
-
diff --git a/test/unittest_textutils.py b/test/unittest_textutils.py
index c878c0f..708149b 100644
--- a/test/unittest_textutils.py
+++ b/test/unittest_textutils.py
@@ -77,7 +77,7 @@ aller discuter avec les autres si c'est utile ou necessaire.""")
> http://www.editions-eni.fr/Livres/Python-Les-fondamentaux-du-langage---La-programmation-pour-les-scientifiques-Table-des-matieres/.20_adaa41fb-c125-4919-aece-049601e81c8e_0_0.pdf
> .. _extrait:
> http://www.editions-eni.fr/Livres/Python-Les-fondamentaux-du-langage---La-programmation-pour-les-scientifiques-Extrait-du-livre/.20_d6eed0be-0d36-4384-be59-2dd09e081012_0_0.pdf""")
-
+
def test_normalize_paragraph2(self):
self.assertEquals(ulines(tu.normalize_paragraph(""".. _tdm: http://www.editions-eni.fr/Livres/Python-Les-fondamentaux-du-langage---La-programmation-pour-les-scientifiques-Table-des-matieres/.20_adaa41fb-c125-4919-aece-049601e81c8e_0_0.pdf
.. _extrait: http://www.editions-eni.fr/Livres/Python-Les-fondamentaux-du-langage---La-programmation-pour-les-scientifiques-Extrait-du-livre/.20_d6eed0be-0d36-4384-be59-2dd09e081012_0_0.pdf""", indent='> ')),
@@ -97,7 +97,7 @@ the tests.""", indent=' ', line_len=70)),
package. It isn't necessary to install this package unless you want
to execute or look at the tests.""")
-
+
class GetCsvTC(TestCase):
def test_known(self):
@@ -114,27 +114,27 @@ class UnitsTC(TestCase):
def test_empty_base(self):
self.assertEquals(tu.apply_units('17', {}), 17)
-
+
def test_empty_inter(self):
def inter(value):
return int(float(value)) * 2
result = tu.apply_units('12.4', {}, inter=inter)
self.assertEquals(result, 12 * 2)
self.assertIsInstance(result, float)
-
+
def test_empty_final(self):
# int('12.4') raise value error
self.assertRaises(ValueError, tu.apply_units,'12.4', {}, final=int)
-
+
def test_empty_inter_final(self):
result = tu.apply_units('12.4', {}, inter=float,final=int)
self.assertEquals(result, 12)
self.assertIsInstance(result, int)
-
+
def test_blank_base(self):
result = tu.apply_units(' 42 ', {}, final=int)
self.assertEquals(result, 42)
-
+
def test_blank_space(self):
result = tu.apply_units(' 1 337 ', {}, final=int)
self.assertEquals(result, 1337)
@@ -154,15 +154,15 @@ class UnitsTC(TestCase):
def test_unit_singleunit_multipleletter(self):
result = tu.apply_units('47KB', self.units)
self.assertEquals(result, 47 * self.units['KB'] )
-
+
def test_unit_multipleunit(self):
result = tu.apply_units('47KB 1.5MB', self.units)
self.assertEquals(result, 47 * self.units['KB'] + 1.5 * self.units['MB'])
-
+
def test_unit_with_blank(self):
result = tu.apply_units('1 000 KB', self.units)
self.assertEquals(result, 1000 * self.units['KB'])
-
+
RGX = re.compile('abcd')
class PrettyMatchTC(TestCase):
@@ -176,7 +176,7 @@ class PrettyMatchTC(TestCase):
match = rgx.search(string)
self.assertEquals(ulines(tu.pretty_match(match, string)), '''toto
^^''')
-
+
def test_known_values_2(self):
rgx = re.compile('(to*)')
string = ''' ... ... to to
@@ -185,8 +185,8 @@ class PrettyMatchTC(TestCase):
self.assertEquals(ulines(tu.pretty_match(match, string)), ''' ... ... to to
^^
... ...''')
-
-
+
+
class UnquoteTC(TestCase):
def test(self):
@@ -194,7 +194,7 @@ class UnquoteTC(TestCase):
self.assertEquals(tu.unquote("'l'inenarrable toto'"), "l'inenarrable toto")
self.assertEquals(tu.unquote("no quote"), "no quote")
-
+
class ColorizeAnsiTC(TestCase):
def test_known(self):
self.assertEquals(tu.colorize_ansi('hello', 'blue', 'strike'), '\x1b[9;34mhello\x1b[0m')
@@ -215,12 +215,12 @@ class UnormalizeTC(TestCase):
]
for input, output in data:
yield self.assertEquals, tu.unormalize(input), output
-
+
class ModuleDocTest(DocTest):
"""test doc test in this module"""
module = tu
# from logilab.common import textutils as module
del DocTest # necessary if we don't want it to be executed (we don't...)
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_tree.py b/test/unittest_tree.py
index 2dd955e..d947c02 100644
--- a/test/unittest_tree.py
+++ b/test/unittest_tree.py
@@ -19,11 +19,11 @@ def make_tree(tuple):
for child in tuple[1]:
n.append(make_tree(child))
return n
-
+
class Node_ClassTest(TestCase):
""" a basic tree node, caracterised by an id"""
def setUp(self):
- """ called before each test from this class """
+ """ called before each test from this class """
self.o = make_tree(tree)
@@ -38,15 +38,15 @@ class Node_ClassTest(TestCase):
result = [r.id for r in resultnodes]
expected = ['root', 'child_1_1', 'child_2_1', 'child_2_2', 'child_3_1', 'child_1_2', 'child_2_3']
self.assertListEqual(result, expected)
-
-
+
+
def test_known_values_remove(self):
- """
+ """
remove a child node
"""
self.o.remove(self.o.get_node_by_id('child_1_1'))
self.assertRaises(NodeNotFound, self.o.get_node_by_id, 'child_1_1')
-
+
def test_known_values_replace(self):
"""
replace a child node with another
@@ -54,44 +54,44 @@ class Node_ClassTest(TestCase):
self.o.replace(self.o.get_node_by_id('child_1_1'), Node('hoho'))
self.assertRaises(NodeNotFound, self.o.get_node_by_id, 'child_1_1')
self.assertEqual(self.o.get_node_by_id('hoho'), self.o.children[0])
-
+
def test_known_values_get_sibling(self):
"""
return the sibling node that has given id
"""
self.assertEqual(self.o.children[0].get_sibling('child_1_2'), self.o.children[1], None)
-
+
def test_raise_get_sibling_NodeNotFound(self):
self.assertRaises(NodeNotFound, self.o.children[0].get_sibling, 'houhou')
-
+
def test_known_values_get_node_by_id(self):
"""
return node in whole hierarchy that has given id
"""
self.assertEqual(self.o.get_node_by_id('child_1_1'), self.o.children[0])
-
+
def test_raise_get_node_by_id_NodeNotFound(self):
self.assertRaises(NodeNotFound, self.o.get_node_by_id, 'houhou')
-
+
def test_known_values_get_child_by_id(self):
"""
return child of given id
"""
self.assertEqual(self.o.get_child_by_id('child_2_1', recurse=1), self.o.children[0].children[0])
-
+
def test_raise_get_child_by_id_NodeNotFound(self):
self.assertRaises(NodeNotFound, self.o.get_child_by_id, nid='child_2_1')
self.assertRaises(NodeNotFound, self.o.get_child_by_id, 'houhou')
-
+
def test_known_values_get_child_by_path(self):
"""
return child of given path (path is a list of ids)
"""
self.assertEqual(self.o.get_child_by_path(['root', 'child_1_1', 'child_2_1']), self.o.children[0].children[0])
-
+
def test_raise_get_child_by_path_NodeNotFound(self):
self.assertRaises(NodeNotFound, self.o.get_child_by_path, ['child_1_1', 'child_2_11'])
-
+
def test_known_values_depth_down(self):
"""
return depth of this node in the tree
@@ -112,13 +112,13 @@ class Node_ClassTest(TestCase):
"""
self.assertEqual(self.o.width(), 3)
self.assertEqual(self.o.get_child_by_id('child_2_1',True).width(), 1)
-
+
def test_known_values_root(self):
"""
return the root node of the tree
"""
self.assertEqual(self.o.get_child_by_id('child_2_1', True).root(), self.o)
-
+
def test_known_values_leaves(self):
"""
return a list with all the leaf nodes descendant from this task
@@ -126,7 +126,7 @@ class Node_ClassTest(TestCase):
self.assertEqual(self.o.leaves(), [self.o.get_child_by_id('child_2_1',True),
self.o.get_child_by_id('child_3_1',True),
self.o.get_child_by_id('child_2_3',True)])
-
+
def test_known_values_lineage(self):
c31 = self.o.get_child_by_id('child_3_1',True)
self.assertEqual(c31.lineage(), [self.o.get_child_by_id('child_3_1',True),
@@ -134,7 +134,7 @@ class Node_ClassTest(TestCase):
self.o.get_child_by_id('child_1_1',True),
self.o])
-
+
class post_order_list_FunctionTest(TestCase):
""""""
def setUp(self):
@@ -142,7 +142,7 @@ class post_order_list_FunctionTest(TestCase):
self.o = make_tree(tree)
def test_known_values_post_order_list(self):
- """
+ """
create a list with tree nodes for which the <filter> function returned true
in a post order foashion
"""
@@ -151,7 +151,7 @@ class post_order_list_FunctionTest(TestCase):
self.assertEqual(l, L, l)
def test_known_values_post_order_list2(self):
- """
+ """
create a list with tree nodes for which the <filter> function returned true
in a post order foashion
"""
@@ -163,7 +163,7 @@ class post_order_list_FunctionTest(TestCase):
l = [n.id for n in post_order_list(self.o, filter)]
self.assertEqual(l, L, l)
-
+
class PostfixedDepthFirstIterator_ClassTest(TestCase):
""""""
def setUp(self):
@@ -179,16 +179,16 @@ class PostfixedDepthFirstIterator_ClassTest(TestCase):
self.assertEqual(o.id, L[i])
o = iter.next()
i += 1
-
-
+
+
class pre_order_list_FunctionTest(TestCase):
""""""
def setUp(self):
""" called before each test from this class """
self.o = make_tree(tree)
-
+
def test_known_values_pre_order_list(self):
- """
+ """
create a list with tree nodes for which the <filter> function returned true
in a pre order fashion
"""
@@ -197,7 +197,7 @@ class pre_order_list_FunctionTest(TestCase):
self.assertEqual(l, L, l)
def test_known_values_pre_order_list2(self):
- """
+ """
create a list with tree nodes for which the <filter> function returned true
in a pre order fashion
"""
@@ -226,6 +226,6 @@ class PrefixedDepthFirstIterator_ClassTest(TestCase):
o = iter.next()
i += 1
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_umessage.py b/test/unittest_umessage.py
index 625fdf9..487a2d7 100644
--- a/test/unittest_umessage.py
+++ b/test/unittest_umessage.py
@@ -6,7 +6,7 @@ from logilab.common.umessage import UMessage, decode_QP
import email
class UMessageTC(TestCase):
-
+
def setUp(self):
msg1 = email.message_from_file(open('data/test1.msg'))
self.umessage1 = UMessage(msg1)
@@ -32,8 +32,7 @@ class UMessageTC(TestCase):
test = decode_QP(test_line)
self.assertEquals(type(test), unicode)
self.assertEquals(test, u'Raphaël DUPONT<raphael.dupont@societe.fr>')
-
+
if __name__ == '__main__':
unittest_main()
-
diff --git a/test/unittest_ureports_html.py b/test/unittest_ureports_html.py
index 9e323b5..d6dcb02 100644
--- a/test/unittest_ureports_html.py
+++ b/test/unittest_ureports_html.py
@@ -11,7 +11,7 @@ class HTMLWriterTC(TestCase, WriterTC):
def setUp(self):
self.writer = HTMLWriter(1)
-
+
# Section tests ###########################################################
section_base = '''<div>
<h1>Section title</h1>
@@ -19,10 +19,10 @@ class HTMLWriterTC(TestCase, WriterTC):
Blabla bla</p></div>
'''
section_nested = '''<div>\n<h1>Section title</h1>\n<p>Section\'s description.\nBlabla bla</p><div>\n<h2>Subsection</h2>\n<p>Sub section description</p></div>\n</div>\n'''
-
+
# List tests ##############################################################
list_base = '''<ul>\n<li>item1</li>\n<li>item2</li>\n<li>item3</li>\n<li>item4</li>\n</ul>\n'''
-
+
nested_list = '''<ul>
<li><p>blabla<ul>
<li>1</li>
@@ -33,7 +33,7 @@ Blabla bla</p></div>
<li>an other point</li>
</ul>
'''
-
+
# Table tests #############################################################
table_base = '''<table>\n<tr class="odd">\n<td>head1</td>\n<td>head2</td>\n</tr>\n<tr class="even">\n<td>cell1</td>\n<td>cell2</td>\n</tr>\n</table>\n'''
field_table = '''<table class="field" id="mytable">\n<tr class="odd">\n<td>f1</td>\n<td>v1</td>\n</tr>\n<tr class="even">\n<td>f22</td>\n<td>v22</td>\n</tr>\n<tr class="odd">\n<td>f333</td>\n<td>v333</td>\n</tr>\n</table>\n'''
@@ -42,6 +42,6 @@ Blabla bla</p></div>
# VerbatimText tests ######################################################
verbatim_base = '''<pre>blablabla</pre>'''
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/unittest_ureports_text.py b/test/unittest_ureports_text.py
index 7e6243e..414fc58 100644
--- a/test/unittest_ureports_text.py
+++ b/test/unittest_ureports_text.py
@@ -31,14 +31,14 @@ Sub section description
'''
-
+
# List tests ##############################################################
list_base = '''
* item1
* item2
* item3
* item4'''
-
+
nested_list = '''
* blabla
- 1
@@ -46,7 +46,7 @@ Sub section description
- 3
* an other point'''
-
+
# Table tests #############################################################
table_base = '''
+------+------+
@@ -83,6 +83,6 @@ f333: v333
blablabla
'''
-
+
if __name__ == '__main__':
unittest_main()
diff --git a/test/utils.py b/test/utils.py
index b654b2f..9dba87b 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -21,33 +21,33 @@ class WriterTC:
print expected
print '****'
raise
-
+
def test_section(self):
layout = Section('Section title',
'Section\'s description.\nBlabla bla')
self._test_output('section_base', layout)
layout.append(Section('Subsection', 'Sub section description'))
self._test_output('section_nested', layout)
-
+
def test_verbatim(self):
layout = VerbatimText('blablabla')
self._test_output('verbatim_base', layout)
-
+
def test_list(self):
layout = List(children=('item1', 'item2', 'item3', 'item4'))
self._test_output('list_base', layout)
-
+
def test_nested_list(self):
layout = List(children=(Paragraph(("blabla", List(children=('1', "2", "3")))),
"an other point"))
self._test_output('nested_list', layout)
-
+
def test_table(self):
layout = Table(cols=2, children=('head1', 'head2', 'cell1', 'cell2'))
self._test_output('table_base', layout)
-
+
def test_field_table(self):
table = Table(cols=2, klass='field', id='mytable')
for field, value in (('f1', 'v1'), ('f22', 'v22'), ('f333', 'v333')):
@@ -64,7 +64,7 @@ class WriterTC:
table.append(Text(''))
self._test_output('advanced_table', table)
-
+
## def test_image(self):
## layout = Verbatim('blablabla')
## self._test_output('verbatim_base', layout)
diff --git a/ureports/__init__.py b/ureports/__init__.py
index 210ec60..f58707b 100644
--- a/ureports/__init__.py
+++ b/ureports/__init__.py
@@ -33,14 +33,14 @@ def get_nodes(node, klass):
# recurse (FIXME: recursion controled by an option)
for grandchild in get_nodes(child, klass):
yield grandchild
-
+
def layout_title(layout):
"""try to return the layout's title as string, return None if not found
"""
for child in layout.children:
if isinstance(child, Title):
return ' '.join([node.data for node in get_nodes(child, Text)])
-
+
def build_summary(layout, level=1):
"""make a summary for the report, including X level"""
assert level > 0
@@ -70,7 +70,7 @@ def build_summary(layout, level=1):
class BaseWriter(object):
"""base class for ureport writers"""
-
+
def format(self, layout, stream=None, encoding=None):
"""format and write the given layout into the stream object
@@ -88,7 +88,7 @@ class BaseWriter(object):
self.begin_format(layout)
layout.accept(self)
self.end_format(layout)
-
+
def format_children(self, layout):
"""recurse on the layout children and call their accept method
(see the Visitor pattern)
@@ -110,7 +110,7 @@ class BaseWriter(object):
def begin_format(self, layout):
"""begin to format a layout"""
self.section = 0
-
+
def end_format(self, layout):
"""finished to format a layout"""
diff --git a/ureports/docbook_writer.py b/ureports/docbook_writer.py
index 8848132..d55068f 100644
--- a/ureports/docbook_writer.py
+++ b/ureports/docbook_writer.py
@@ -19,7 +19,7 @@ from logilab.common.ureports import HTMLWriter
class DocbookWriter(HTMLWriter):
"""format layouts as HTML"""
-
+
def begin_format(self, layout):
"""begin to format a layout"""
super(HTMLWriter, self).begin_format(layout)
@@ -29,7 +29,7 @@ class DocbookWriter(HTMLWriter):
<book xmlns:xi='http://www.w3.org/2001/XInclude'
lang='fr'>
""")
-
+
def end_format(self, layout):
"""finished to format a layout"""
if self.snippet is None:
@@ -58,9 +58,9 @@ class DocbookWriter(HTMLWriter):
self.writeln(self._indent(' <table%s><title>%s</title>' \
% (self.handle_attrs(layout), layout.title)))
self.writeln(self._indent(' <tgroup cols="%s">'% layout.cols))
- for i in range(layout.cols):
+ for i in range(layout.cols):
self.writeln(self._indent(' <colspec colname="c%s" colwidth="1*"/>' % i))
-
+
table_content = self.get_table_content(layout)
# write headers
if layout.cheaders:
@@ -93,27 +93,27 @@ class DocbookWriter(HTMLWriter):
cell = row[j] or '&#160;'
self.writeln(' <entry>%s</entry>' % cell)
self.writeln(self._indent(' </row>'))
-
+
def visit_list(self, layout):
"""display a list (using <itemizedlist>)"""
self.writeln(self._indent(' <itemizedlist%s>' % self.handle_attrs(layout)))
for row in list(self.compute_content(layout)):
self.writeln(' <listitem><para>%s</para></listitem>' % row)
self.writeln(self._indent(' </itemizedlist>'))
-
+
def visit_paragraph(self, layout):
"""display links (using <para>)"""
self.write(self._indent(' <para>'))
self.format_children(layout)
self.writeln('</para>')
-
+
def visit_span(self, layout):
"""display links (using <p>)"""
#TODO: translate in docbook
self.write('<literal %s>' % self.handle_attrs(layout))
self.format_children(layout)
self.write('</literal>')
-
+
def visit_link(self, layout):
"""display links (using <ulink>)"""
self.write('<ulink url="%s"%s>%s</ulink>' % (layout.url,
@@ -125,11 +125,11 @@ class DocbookWriter(HTMLWriter):
self.writeln(self._indent(' <programlisting>'))
self.write(layout.data.replace('&', '&amp;').replace('<', '&lt;'))
self.writeln(self._indent(' </programlisting>'))
-
+
def visit_text(self, layout):
"""add some text"""
self.write(layout.data.replace('&', '&amp;').replace('<', '&lt;'))
-
+
def _indent(self, string):
"""correctly indent string according to section"""
- return ' ' * 2*(self.section) + string
+ return ' ' * 2*(self.section) + string
diff --git a/ureports/html_writer.py b/ureports/html_writer.py
index 930aff7..45ae9c5 100644
--- a/ureports/html_writer.py
+++ b/ureports/html_writer.py
@@ -21,11 +21,11 @@ from logilab.common.ureports import BaseWriter
class HTMLWriter(BaseWriter):
"""format layouts as HTML"""
-
+
def __init__(self, snippet=None):
super(HTMLWriter, self).__init__()
self.snippet = snippet
-
+
def handle_attrs(self, layout):
"""get an attribute string from layout member attributes"""
attrs = ''
@@ -36,14 +36,14 @@ class HTMLWriter(BaseWriter):
if nid:
attrs += ' id="%s"' % nid
return attrs
-
+
def begin_format(self, layout):
"""begin to format a layout"""
super(HTMLWriter, self).begin_format(layout)
if self.snippet is None:
self.writeln('<html>')
self.writeln('<body>')
-
+
def end_format(self, layout):
"""finished to format a layout"""
if self.snippet is None:
@@ -88,26 +88,26 @@ class HTMLWriter(BaseWriter):
self.writeln('<td>%s</td>' % cell)
self.writeln('</tr>')
self.writeln('</table>')
-
+
def visit_list(self, layout):
"""display a list as html"""
self.writeln('<ul%s>' % self.handle_attrs(layout))
for row in list(self.compute_content(layout)):
self.writeln('<li>%s</li>' % row)
self.writeln('</ul>')
-
+
def visit_paragraph(self, layout):
"""display links (using <p>)"""
self.write('<p>')
self.format_children(layout)
self.write('</p>')
-
+
def visit_span(self, layout):
"""display links (using <p>)"""
self.write('<span%s>' % self.handle_attrs(layout))
self.format_children(layout)
self.write('</span>')
-
+
def visit_link(self, layout):
"""display links (using <a>)"""
self.write(' <a href="%s"%s>%s</a>' % (layout.url,
@@ -118,7 +118,7 @@ class HTMLWriter(BaseWriter):
self.write('<pre>')
self.write(layout.data.replace('&', '&amp;').replace('<', '&lt;'))
self.write('</pre>')
-
+
def visit_text(self, layout):
"""add some text"""
data = layout.data
diff --git a/ureports/nodes.py b/ureports/nodes.py
index 3807a4c..8992d31 100644
--- a/ureports/nodes.py
+++ b/ureports/nodes.py
@@ -48,14 +48,14 @@ class BaseLayout(BaseComponent):
"""overridden to detect problems easily"""
assert child not in self.parents()
VNode.append(self, child)
-
+
def parents(self):
"""return the ancestor nodes"""
assert self.parent is not self
if self.parent is None:
return []
return [self.parent] + self.parent.parents()
-
+
def add_text(self, text):
"""shortcut to add text data"""
self.children.append(Text(text))
@@ -85,7 +85,7 @@ class VerbatimText(Text):
* BaseComponent attributes
* data : the text value as an encoded or unicode string
"""
-
+
class Link(BaseComponent):
"""a labelled link
@@ -100,7 +100,7 @@ class Link(BaseComponent):
self.url = url
self.label = label or url
-
+
class Image(BaseComponent):
"""an embeded or a single image
@@ -118,15 +118,15 @@ class Image(BaseComponent):
self.stream = stream
self.title = title
-
+
# container nodes #############################################################
-
+
class Section(BaseLayout):
"""a section
attributes :
* BaseLayout attributes
-
+
a title may also be given to the constructor, it'll be added
as a first element
a description may also be given to the constructor, it'll be added
@@ -138,34 +138,34 @@ class Section(BaseLayout):
self.insert(0, Paragraph([Text(description)]))
if title:
self.insert(0, Title(children=(title,)))
-
+
class Title(BaseLayout):
"""a title
-
+
attributes :
* BaseLayout attributes
A title must not contains a section nor a paragraph!
"""
-
+
class Span(BaseLayout):
"""a title
-
+
attributes :
* BaseLayout attributes
A span should only contains Text and Link nodes (in-line elements)
"""
-
+
class Paragraph(BaseLayout):
"""a simple text paragraph
-
+
attributes :
* BaseLayout attributes
A paragraph must not contains a section !
"""
-
+
class Table(BaseLayout):
"""some tabular data
@@ -175,7 +175,7 @@ class Table(BaseLayout):
* rheaders : the first row's elements are table's header
* cheaders : the first col's elements are table's header
* title : the table's optional title
- """
+ """
def __init__(self, cols, title=None,
rheaders=0, cheaders=0, rrheaders=0, rcheaders=0,
**kwargs):
@@ -187,10 +187,10 @@ class Table(BaseLayout):
self.cheaders = cheaders
self.rrheaders = rrheaders
self.rcheaders = rcheaders
-
+
class List(BaseLayout):
"""some list data
attributes :
* BaseLayout attributes
- """
+ """
diff --git a/ureports/text_writer.py b/ureports/text_writer.py
index 437d88b..e8bab0d 100644
--- a/ureports/text_writer.py
+++ b/ureports/text_writer.py
@@ -20,7 +20,7 @@ from logilab.common.ureports import BaseWriter
TITLE_UNDERLINES = ['', '=', '-', '`', '.', '~', '^']
BULLETS = ['*', '-']
-
+
class TextWriter(BaseWriter):
"""format layouts as text
(ReStructured inspiration but not totally handled yet)
@@ -29,7 +29,7 @@ class TextWriter(BaseWriter):
super(TextWriter, self).begin_format(layout)
self.list_level = 0
self.pending_urls = []
-
+
def visit_section(self, layout):
"""display a section as text
"""
@@ -43,7 +43,7 @@ class TextWriter(BaseWriter):
self.pending_urls = []
self.section -= 1
self.writeln()
-
+
def visit_title(self, layout):
title = ''.join(list(self.compute_content(layout)))
self.writeln(title)
@@ -51,16 +51,16 @@ class TextWriter(BaseWriter):
self.writeln(TITLE_UNDERLINES[self.section] * len(title))
except IndexError:
print "FIXME TITLE TOO DEEP. TURNING TITLE INTO TEXT"
-
+
def visit_paragraph(self, layout):
"""enter a paragraph"""
self.format_children(layout)
self.writeln()
-
+
def visit_span(self, layout):
"""enter a span"""
self.format_children(layout)
-
+
def visit_table(self, layout):
"""display a table as text"""
table_content = self.get_table_content(layout)
@@ -75,7 +75,7 @@ class TextWriter(BaseWriter):
else:
self.default_table(layout, table_content, cols_width)
self.writeln()
-
+
def default_table(self, layout, table_content, cols_width):
"""format a table"""
cols_width = [size+1 for size in cols_width]
@@ -96,14 +96,14 @@ class TextWriter(BaseWriter):
self.write(headsep)
else:
self.write(table_linesep)
-
+
def field_table(self, layout, table_content, cols_width):
"""special case for field table"""
assert layout.cols == 2
format_string = '%s%%-%ss: %%s' % (linesep, cols_width[0])
for field, value in table_content:
self.write(format_string % (field, value))
-
+
def visit_list(self, layout):
"""display a list layout as text"""
@@ -122,7 +122,7 @@ class TextWriter(BaseWriter):
self.pending_urls.append( (layout.label, layout.url) )
else:
self.write(layout.url)
-
+
def visit_verbatimtext(self, layout):
"""display a verbatim layout as text (so difficult ;)
"""
@@ -130,9 +130,7 @@ class TextWriter(BaseWriter):
for line in layout.data.splitlines():
self.writeln(' ' + line)
self.writeln()
-
+
def visit_text(self, layout):
"""add some text"""
self.write(layout.data)
-
-