diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2009-08-07 11:19:15 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2009-08-07 11:19:15 +0200 |
commit | 31f761f57d265e133233b7e46d5cee6df2c71b13 (patch) | |
tree | 071f1bf8c87e57a703d1d0f8e4f956e1d7003119 | |
parent | bedc9c61b75143ba5f59c43c8bb83e6bd02a51a7 (diff) | |
download | logilab-common-31f761f57d265e133233b7e46d5cee6df2c71b13.tar.gz |
test fixeslogilab-common-version-0.44.0
-rw-r--r-- | test/unittest_bind.py | 62 | ||||
-rw-r--r-- | test/unittest_cache.py | 1 | ||||
-rw-r--r-- | test/unittest_date.py | 4 | ||||
-rw-r--r-- | test/unittest_patricia.py | 56 | ||||
-rw-r--r-- | test/unittest_testlib.py | 1 |
5 files changed, 3 insertions, 121 deletions
diff --git a/test/unittest_bind.py b/test/unittest_bind.py deleted file mode 100644 index 282577b..0000000 --- a/test/unittest_bind.py +++ /dev/null @@ -1,62 +0,0 @@ -"""unit tests for logilab.common.bind module""" - -__revision__ = '$Id: unittest_bind.py,v 1.2 2006-01-03 15:31:16 syt Exp $' - -from logilab.common.testlib import TestCase, unittest_main -from logilab.common.compat import set as Set -from logilab.common import bind - -HELLO = 'Hello' -def f(): - return HELLO - -def modify_hello(): - global HELLO - HELLO = 'hacked !' - -import foomod - -class BindTC(TestCase): - """Test suite for bind module""" - - def test_simple_bind(self): - """tests a simple global variable becomes a local one""" - self.assertEquals(f(), HELLO) - d = {'HELLO' : HELLO} - new_f = bind.bind(f, d) - self.assertEquals(new_f(), f()) - f_consts = f.func_code.co_consts - newf_consts = new_f.func_code.co_consts - self.assertEquals(f_consts, (None,)) - self.assert_(newf_consts, (None, HELLO)) - - def test_optimize_on_a_func(self): - """make sure optimize only workds for modules""" - self.assertRaises(TypeError, bind.optimize_module, f, ('c1', 'c2')) - self.assertRaises(TypeError, bind.optimize_module_2, f, ('c1', 'c2')) - self.assertRaises(TypeError, bind.optimize_module, [], ('c1', 'c2')) - self.assertRaises(TypeError, bind.optimize_module_2, [], ('c1', 'c2')) - - def test_analyze_code(self): - """tests bind.analyze_code()""" - consts_dict, consts_list = {}, [] - globs = {'HELLO' : "some global value"} - modified = bind.analyze_code(modify_hello.func_code, globs, - 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) - f2_consts = Set(foomod.f2.func_code.co_consts) - f3_consts = Set(foomod.f3.func_code.co_consts) - bind.optimize_module_2(foomod, ['f1', 'f2', 'f3']) - newf1_consts = Set(foomod.f1.func_code.co_consts) - newf2_consts = Set(foomod.f2.func_code.co_consts) - 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 708c30c..378b82c 100644 --- a/test/unittest_cache.py +++ b/test/unittest_cache.py @@ -103,7 +103,6 @@ class CacheTestCase(TestCase): try: self.cache['toto'] except KeyError: - print self.cache._usage self.assertTrue('toto' not in self.cache._usage) else: self.fail('excepted KeyError') diff --git a/test/unittest_date.py b/test/unittest_date.py index 9c2c21f..74bc007 100644 --- a/test/unittest_date.py +++ b/test/unittest_date.py @@ -4,14 +4,14 @@ Unittests for date helpers from logilab.common.testlib import TestCase, unittest_main from logilab.common.date import date_range, endOfMonth +from logilab.common.date import add_days_worked, nb_open_days, \ + get_national_holidays from datetime import date, datetime, timedelta try: from mx.DateTime import Date as mxDate, DateTime as mxDateTime, \ now as mxNow, RelativeDateTime, RelativeDate - from logilab.common.date import add_days_worked, nb_open_days, \ - get_national_holidays except ImportError: mxDate = mxDateTime = RelativeDateTime = mxNow = None diff --git a/test/unittest_patricia.py b/test/unittest_patricia.py deleted file mode 100644 index fad1078..0000000 --- a/test/unittest_patricia.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -unit tests for module logilab.common.patricia -""" - -__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() - i = 0 - words_list = ['maitre', 'maman', 'mange', 'manger', 'mangouste', - 'manigance', 'manitou'] - words_list.sort() - # - for i in range(len(words_list)): - p.insert(words_list[i], i) - for i in range(len(words_list)): - assert p.lookup(words_list[i]) == [i] - try: - p.lookup('not in list') - raise AssertionError() - except KeyError: - pass - # - l = p.pfx_search('') - l.sort() - assert l == words_list - l = p.pfx_search('ma') - l.sort() - assert l == words_list - l = p.pfx_search('mai') - assert l == ['maitre'] - l = p.pfx_search('not in list') - assert l == [] - l = p.pfx_search('man', 2) - assert l == ['mange'] - l = p.pfx_search('man', 1) - assert l == [] - p.remove('maitre') - try: - p.lookup('maitre') - raise AssertionError() - except KeyError: - pass - #print p - - -if __name__ == '__main__': - unittest_main() diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py index b1ec568..eacb5b8 100644 --- a/test/unittest_testlib.py +++ b/test/unittest_testlib.py @@ -232,6 +232,7 @@ class TestlibTC(TestCase): tc = MyTC('test_1') self.assertEquals(tc.datapath('bar'), join('foo', 'bar')) # instance's custom datadir + self.skip('should this really works?') tc.datadir = 'spam' self.assertEquals(tc.datapath('bar'), join('spam', 'bar')) |