summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2012-08-29 14:41:32 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2012-08-29 14:41:32 +0200
commitb043897376ecd3ca84aff81e4dd33890f696431c (patch)
treef5bba9b2b93f3f2fa46a2ee538197c14b58c0d06
parentb7d1747e918a9da690ea13c4ef9e15a5786c94bc (diff)
downloadlogilab-common-b043897376ecd3ca84aff81e4dd33890f696431c.tar.gz
silent unittest2 warnings
-rw-r--r--modutils.py2
-rw-r--r--test/unittest_cache.py10
-rw-r--r--test/unittest_changelog.py7
-rw-r--r--test/unittest_date.py4
-rw-r--r--test/unittest_decorators.py6
-rw-r--r--test/unittest_fileutils.py54
-rw-r--r--test/unittest_modutils.py8
-rw-r--r--test/unittest_shellutils.py4
-rw-r--r--test/unittest_table.py18
-rw-r--r--test/unittest_testlib.py2
-rw-r--r--test/unittest_umessage.py2
-rw-r--r--testlib.py14
12 files changed, 67 insertions, 64 deletions
diff --git a/modutils.py b/modutils.py
index ebad473..2cae005 100644
--- a/modutils.py
+++ b/modutils.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
diff --git a/test/unittest_cache.py b/test/unittest_cache.py
index c184cca..9b02b39 100644
--- a/test/unittest_cache.py
+++ b/test/unittest_cache.py
@@ -1,5 +1,5 @@
# unit tests for the cache module
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -68,9 +68,9 @@ class CacheTestCase(TestCase):
self.cache[4] = 'foz'
self.cache[5] = 'fuz'
self.cache[6] = 'spam'
- self.assert_(1 not in self.cache,
+ self.assertTrue(1 not in self.cache,
'key 1 has not been suppressed from the cache dictionnary')
- self.assert_(1 not in self.cache._usage,
+ self.assertTrue(1 not in self.cache._usage,
'key 1 has not been suppressed from the cache LRU list')
self.assertEqual(len(self.cache._usage), 5, "lenght of usage list is not 5")
self.assertEqual(self.cache._usage[-1], 6, '6 is not the most recently used key')
@@ -95,8 +95,8 @@ class CacheTestCase(TestCase):
"""
self.cache['foo'] = 'bar'
del self.cache['foo']
- self.assert_('foo' not in self.cache.keys(), "Element 'foo' was not removed cache dictionnary")
- self.assert_('foo' not in self.cache._usage, "Element 'foo' was not removed usage list")
+ self.assertTrue('foo' not in self.cache.keys(), "Element 'foo' was not removed cache dictionnary")
+ self.assertTrue('foo' not in self.cache._usage, "Element 'foo' was not removed usage list")
self.assertItemsEqual(self.cache._usage,
self.cache.keys())# usage list and data keys are different
diff --git a/test/unittest_changelog.py b/test/unittest_changelog.py
index 4db67ef..dff9979 100644
--- a/test/unittest_changelog.py
+++ b/test/unittest_changelog.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -15,6 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import with_statement
+
from os.path import join, dirname
from cStringIO import StringIO
@@ -30,7 +32,8 @@ class ChangeLogTC(TestCase):
cl = self.cl_class(self.cl_file)
out = StringIO()
cl.write(out)
- self.assertStreamEquals(open(self.cl_file), out)
+ with open(self.cl_file) as stream:
+ self.assertMultiLineEqual(stream.read(), out.getvalue())
if __name__ == '__main__':
diff --git a/test/unittest_date.py b/test/unittest_date.py
index 8fa7776..0aa1de8 100644
--- a/test/unittest_date.py
+++ b/test/unittest_date.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -147,7 +147,7 @@ class MxDateTC(DateTC):
def check_mx(self):
if mxDate is None:
- self.skip('mx.DateTime is not installed')
+ self.skipTest('mx.DateTime is not installed')
def setUp(self):
self.check_mx()
diff --git a/test/unittest_decorators.py b/test/unittest_decorators.py
index 49661a6..40eddc2 100644
--- a/test/unittest_decorators.py
+++ b/test/unittest_decorators.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -177,9 +177,9 @@ class DecoratorsTC(TestCase):
foo = Foo()
self.assertEqual(Foo.x, 0)
- self.failIf('bar' in foo.__dict__)
+ self.assertFalse('bar' in foo.__dict__)
self.assertEqual(foo.bar, 1)
- self.failUnless('bar' in foo.__dict__)
+ self.assertTrue('bar' in foo.__dict__)
self.assertEqual(foo.bar, 1)
self.assertEqual(foo.quux, 42)
self.assertEqual(Foo.bar.__doc__,
diff --git a/test/unittest_fileutils.py b/test/unittest_fileutils.py
index b7ffd71..274ba9a 100644
--- a/test/unittest_fileutils.py
+++ b/test/unittest_fileutils.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -73,10 +73,10 @@ class ExportTC(TestCase):
def test(self):
export(DATA_DIR, self.tempdir, verbose=0)
- self.assert_(exists(join(self.tempdir, '__init__.py')))
- self.assert_(exists(join(self.tempdir, 'sub')))
- self.assert_(not exists(join(self.tempdir, '__init__.pyc')))
- self.assert_(not exists(join(self.tempdir, 'CVS')))
+ self.assertTrue(exists(join(self.tempdir, '__init__.py')))
+ self.assertTrue(exists(join(self.tempdir, 'sub')))
+ self.assertTrue(not exists(join(self.tempdir, '__init__.pyc')))
+ self.assertTrue(not exists(join(self.tempdir, 'CVS')))
def tearDown(self):
shutil.rmtree(self.tempdir)
@@ -93,43 +93,43 @@ class ProtectedFileTC(TestCase):
def test_mode_change(self):
"""tests that mode is changed when needed"""
# test on non-writable file
- #self.assert_(not os.access(self.rpath, os.W_OK))
- self.assert_(not os.stat(self.rpath).st_mode & S_IWRITE)
+ #self.assertTrue(not os.access(self.rpath, os.W_OK))
+ self.assertTrue(not os.stat(self.rpath).st_mode & S_IWRITE)
wp_file = ProtectedFile(self.rpath, 'w')
- self.assert_(os.stat(self.rpath).st_mode & S_IWRITE)
- self.assert_(os.access(self.rpath, os.W_OK))
+ self.assertTrue(os.stat(self.rpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rpath, os.W_OK))
# test on writable-file
- self.assert_(os.stat(self.rwpath).st_mode & S_IWRITE)
- self.assert_(os.access(self.rwpath, os.W_OK))
+ self.assertTrue(os.stat(self.rwpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rwpath, os.W_OK))
wp_file = ProtectedFile(self.rwpath, 'w')
- self.assert_(os.stat(self.rwpath).st_mode & S_IWRITE)
- self.assert_(os.access(self.rwpath, os.W_OK))
+ self.assertTrue(os.stat(self.rwpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rwpath, os.W_OK))
def test_restore_on_close(self):
"""tests original mode is restored on close"""
# test on non-writable file
- #self.assert_(not os.access(self.rpath, os.W_OK))
- self.assert_(not os.stat(self.rpath).st_mode & S_IWRITE)
+ #self.assertTrue(not os.access(self.rpath, os.W_OK))
+ self.assertTrue(not os.stat(self.rpath).st_mode & S_IWRITE)
ProtectedFile(self.rpath, 'w').close()
- #self.assert_(not os.access(self.rpath, os.W_OK))
- self.assert_(not os.stat(self.rpath).st_mode & S_IWRITE)
+ #self.assertTrue(not os.access(self.rpath, os.W_OK))
+ self.assertTrue(not os.stat(self.rpath).st_mode & S_IWRITE)
# test on writable-file
- self.assert_(os.access(self.rwpath, os.W_OK))
- self.assert_(os.stat(self.rwpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rwpath, os.W_OK))
+ self.assertTrue(os.stat(self.rwpath).st_mode & S_IWRITE)
ProtectedFile(self.rwpath, 'w').close()
- self.assert_(os.access(self.rwpath, os.W_OK))
- self.assert_(os.stat(self.rwpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rwpath, os.W_OK))
+ self.assertTrue(os.stat(self.rwpath).st_mode & S_IWRITE)
def test_mode_change_on_append(self):
"""tests that mode is changed when file is opened in 'a' mode"""
- #self.assert_(not os.access(self.rpath, os.W_OK))
- self.assert_(not os.stat(self.rpath).st_mode & S_IWRITE)
+ #self.assertTrue(not os.access(self.rpath, os.W_OK))
+ self.assertTrue(not os.stat(self.rpath).st_mode & S_IWRITE)
wp_file = ProtectedFile(self.rpath, 'a')
- self.assert_(os.access(self.rpath, os.W_OK))
- self.assert_(os.stat(self.rpath).st_mode & S_IWRITE)
+ self.assertTrue(os.access(self.rpath, os.W_OK))
+ self.assertTrue(os.stat(self.rpath).st_mode & S_IWRITE)
wp_file.close()
- #self.assert_(not os.access(self.rpath, os.W_OK))
- self.assert_(not os.stat(self.rpath).st_mode & S_IWRITE)
+ #self.assertTrue(not os.access(self.rpath, os.W_OK))
+ self.assertTrue(not os.stat(self.rpath).st_mode & S_IWRITE)
from logilab.common.testlib import DocTest
diff --git a/test/unittest_modutils.py b/test/unittest_modutils.py
index 6a2b62e..2218da5 100644
--- a/test/unittest_modutils.py
+++ b/test/unittest_modutils.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -260,9 +260,9 @@ class get_modules_files_tc(ModutilsTestCase):
del logilab.common.fileutils
del sys.modules['logilab.common.fileutils']
m = modutils.load_module_from_modpath(['logilab', 'common', 'fileutils'])
- self.assert_( hasattr(logilab, 'common') )
- self.assert_( hasattr(logilab.common, 'fileutils') )
- self.assert_( m is logilab.common.fileutils )
+ self.assertTrue( hasattr(logilab, 'common') )
+ self.assertTrue( hasattr(logilab.common, 'fileutils') )
+ self.assertTrue( m is logilab.common.fileutils )
from logilab.common.testlib import DocTest
class ModuleDocTest(DocTest):
diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py
index fb9e1ca..3bf6bc9 100644
--- a/test/unittest_shellutils.py
+++ b/test/unittest_shellutils.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -155,7 +155,7 @@ class ProgressBarTC(TestCase):
dots /= 5
expected_stream.write("\r["+('.'*dots)+(' '*(size-dots))+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
-
+
def test_update_relative(self):
pgb_stream = StringIO()
expected_stream = StringIO()
diff --git a/test/unittest_table.py b/test/unittest_table.py
index 57fea86..d2db8b7 100644
--- a/test/unittest_table.py
+++ b/test/unittest_table.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -65,14 +65,14 @@ class TableTC(TestCase):
def test_indexation(self):
"""we should be able to use [] to access rows"""
- self.assert_(self.table[0] == self.table.data[0])
- self.assert_(self.table[1] == self.table.data[1])
+ self.assertTrue(self.table[0] == self.table.data[0])
+ self.assertTrue(self.table[1] == self.table.data[1])
def test_iterable(self):
"""test iter(table)"""
it = iter(self.table)
- self.assert_(it.next() == self.table.data[0])
- self.assert_(it.next() == self.table.data[1])
+ self.assertTrue(it.next() == self.table.data[0])
+ self.assertTrue(it.next() == self.table.data[1])
def test_get_rows(self):
"""tests Table.get_rows()"""
@@ -308,7 +308,7 @@ class TableStyleSheetTC(TestCase):
self.stylesheet.add_rowavg_rule((0, 2), 0, 0, 1)
self.table.apply_stylesheet(self.stylesheet)
val = self.table[0, 2]
- self.assert_(int(val) == 15)
+ self.assertTrue(int(val) == 15)
def test_rowsum_rule(self):
@@ -318,7 +318,7 @@ class TableStyleSheetTC(TestCase):
self.stylesheet.add_rowsum_rule((0, 2), 0, 0, 1)
self.table.apply_stylesheet(self.stylesheet)
val = self.table[0, 2]
- self.assert_(val == 30)
+ self.assertTrue(val == 30)
def test_colavg_rule(self):
@@ -330,7 +330,7 @@ class TableStyleSheetTC(TestCase):
self.stylesheet.add_colavg_rule((2, 0), 0, 0, 1)
self.table.apply_stylesheet(self.stylesheet)
val = self.table[2, 0]
- self.assert_(int(val) == 11)
+ self.assertTrue(int(val) == 11)
def test_colsum_rule(self):
@@ -342,7 +342,7 @@ class TableStyleSheetTC(TestCase):
self.stylesheet.add_colsum_rule((2, 0), 0, 0, 1)
self.table.apply_stylesheet(self.stylesheet)
val = self.table[2, 0]
- self.assert_(val == 22)
+ self.assertTrue(val == 22)
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py
index 9672560..e7becf8 100644
--- a/test/unittest_testlib.py
+++ b/test/unittest_testlib.py
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
diff --git a/test/unittest_umessage.py b/test/unittest_umessage.py
index 2d14a26..6bf56c6 100644
--- a/test/unittest_umessage.py
+++ b/test/unittest_umessage.py
@@ -1,5 +1,5 @@
# encoding: iso-8859-15
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
diff --git a/testlib.py b/testlib.py
index 41ffb5f..9dd541b 100644
--- a/testlib.py
+++ b/testlib.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -1024,7 +1024,7 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
partial_iter = True
- self.assert_(ipath_a == ipath_b,
+ self.assertTrue(ipath_a == ipath_b,
"unexpected %s in %s while looking %s from %s" %
(ipath_a, path_a, ipath_b, path_b))
@@ -1082,9 +1082,9 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
msg = '%r is not an instance of %s but of %s'
msg = msg % (obj, klass, type(obj))
if strict:
- self.assert_(obj.__class__ is klass, msg)
+ self.assertTrue(obj.__class__ is klass, msg)
else:
- self.assert_(isinstance(obj, klass), msg)
+ self.assertTrue(isinstance(obj, klass), msg)
@deprecated('Please use assertIsNone instead.')
def assertNone(self, obj, msg=None):
@@ -1094,14 +1094,14 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
"""
if msg is None:
msg = "reference to %r when None expected"%(obj,)
- self.assert_( obj is None, msg )
+ self.assertTrue( obj is None, msg )
@deprecated('Please use assertIsNotNone instead.')
def assertNotNone(self, obj, msg=None):
"""assert obj is not None"""
if msg is None:
msg = "unexpected reference to None"
- self.assert_( obj is not None, msg )
+ self.assertTrue( obj is not None, msg )
@deprecated('Non-standard. Please use assertAlmostEqual instead.')
def assertFloatAlmostEquals(self, obj, other, prec=1e-5,
@@ -1119,7 +1119,7 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
msg = "%r != %r" % (obj, other)
if relative:
prec = prec*math.fabs(obj)
- self.assert_(math.fabs(obj - other) < prec, msg)
+ self.assertTrue(math.fabs(obj - other) < prec, msg)
def failUnlessRaises(self, excClass, callableObj=None, *args, **kwargs):
"""override default failUnlessRaises method to return the raised