cleanups
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 08 Oct 2010 11:11:08 +0200
changeset 6415 b0b0f097a72d
parent 6413 c1a85c1ce131
child 6416 2ca48e45522e
cleanups
server/test/unittest_ldapuser.py
sobjects/test/unittest_notification.py
test/unittest_dbapi.py
test/unittest_entity.py
test/unittest_rset.py
test/unittest_schema.py
test/unittest_utils.py
web/test/unittest_urlpublisher.py
--- a/server/test/unittest_ldapuser.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/server/test/unittest_ldapuser.py	Fri Oct 08 11:11:08 2010 +0200
@@ -15,9 +15,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""cubicweb.server.sources.ldapusers unit and functional tests
-
-"""
+"""cubicweb.server.sources.ldapusers unit and functional tests"""
 
 import socket
 
--- a/sobjects/test/unittest_notification.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/sobjects/test/unittest_notification.py	Fri Oct 08 11:11:08 2010 +0200
@@ -58,7 +58,7 @@
     def test_nonregr_empty_message_id(self):
         for eid in (1, 12, 123, 1234):
             msgid1 = construct_message_id('testapp', eid, 12)
-            self.assertNotEquals(msgid1, '<@testapp.%s>' % gethostname())
+            self.assertNotEqual(msgid1, '<@testapp.%s>' % gethostname())
 
 
 class RecipientsFinderTC(CubicWebTC):
--- a/test/unittest_dbapi.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/test/unittest_dbapi.py	Fri Oct 08 11:11:08 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""
+"""unittest for cubicweb.dbapi"""
 
-"""
 from __future__ import with_statement
 from copy import copy
 
--- a/test/unittest_entity.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/test/unittest_entity.py	Fri Oct 08 11:11:08 2010 +0200
@@ -317,7 +317,7 @@
 
     def test_printable_value_string(self):
         e = self.request().create_entity('Card', title=u'rest test', content=u'du :eid:`1:*ReST*`',
-                            content_format=u'text/rest')
+                                         content_format=u'text/rest')
         self.assertEqual(e.printable_value('content'),
                           '<p>du <a class="reference" href="http://testing.fr/cubicweb/cwgroup/guests">*ReST*</a></p>\n')
         e.cw_attr_cache['content'] = 'du <em>html</em> <ref rql="CWUser X">users</ref>'
@@ -393,7 +393,7 @@
         self.assertEqual(tidy(e.printable_value('content')), u'R&amp;D;')
         e.cw_attr_cache['content'] = u'yo !! R&amp;D <div> pas fermé'
         self.assertEqual(tidy(e.printable_value('content')),
-                          u'yo !! R&amp;D <div> pas fermé</div>')
+                         u'yo !! R&amp;D <div> pas fermé</div>')
         e.cw_attr_cache['content'] = u'été <div> été'
         self.assertEqual(tidy(e.printable_value('content')),
         e.cw_attr_cache['content'] = u'C&apos;est un exemple s&eacute;rieux'
@@ -497,7 +497,7 @@
         self.assertEqual(card3.rest_path(), 'card/eid/%d' % card3.eid)
         card4 = req.create_entity('Card', title=u'pod', wikiid=u'zo?bi')
         self.assertEqual(card4.rest_path(), 'card/eid/%d' % card4.eid)
-        
+
 
     def test_set_attributes(self):
         req = self.request()
--- a/test/unittest_rset.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/test/unittest_rset.py	Fri Oct 08 11:11:08 2010 +0200
@@ -281,7 +281,7 @@
         e = rset.get_entity(0, 0)
         self.assertEqual(e.cw_attr_cache['title'], 'zou')
         self.assertEqual(pprelcachedict(e._cw_related_cache),
-                          [('created_by_subject', [5])])
+                          [('created_by_subject', [self.user().eid])])
         # first level of recursion
         u = e.created_by[0]
         self.assertEqual(u.cw_attr_cache['login'], 'admin')
--- a/test/unittest_schema.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/test/unittest_schema.py	Fri Oct 08 11:11:08 2010 +0200
@@ -167,8 +167,7 @@
         schema = loader.load(config)
         self.assert_(isinstance(schema, CubicWebSchema))
         self.assertEqual(schema.name, 'data')
-        entities = [str(e) for e in schema.entities()]
-        entities.sort()
+        entities = sorted([str(e) for e in schema.entities()])
         expected_entities = ['BaseTransition', 'Bookmark', 'Boolean', 'Bytes', 'Card',
                              'Date', 'Datetime', 'Decimal',
                              'CWCache', 'CWConstraint', 'CWConstraintType', 'CWEType',
@@ -182,8 +181,7 @@
                              'Tag', 'Time', 'Transition', 'TrInfo',
                              'Workflow', 'WorkflowTransition']
         self.assertListEqual(entities, sorted(expected_entities))
-        relations = [str(r) for r in schema.relations()]
-        relations.sort()
+        relations = sorted([str(r) for r in schema.relations()])
         expected_relations = ['add_permission', 'address', 'alias', 'allowed_transition',
                               'bookmarked_by', 'by_transition',
 
@@ -308,7 +306,7 @@
     def test_comparison(self):
         self.assertEqual(ERQLExpression('X is CWUser', 'X', 0),
                           ERQLExpression('X is CWUser', 'X', 0))
-        self.assertNotEquals(ERQLExpression('X is CWUser', 'X', 0),
+        self.assertNotEqual(ERQLExpression('X is CWUser', 'X', 0),
                              ERQLExpression('X is CWGroup', 'X', 0))
 
 class GuessRrqlExprMainVarsTC(TestCase):
--- a/test/unittest_utils.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/test/unittest_utils.py	Fri Oct 08 11:11:08 2010 +0200
@@ -33,8 +33,8 @@
 
 class MakeUidTC(TestCase):
     def test_1(self):
-        self.assertNotEquals(make_uid('xyz'), make_uid('abcd'))
-        self.assertNotEquals(make_uid('xyz'), make_uid('xyz'))
+        self.assertNotEqual(make_uid('xyz'), make_uid('abcd'))
+        self.assertNotEqual(make_uid('xyz'), make_uid('xyz'))
 
     def test_2(self):
         d = set()
--- a/web/test/unittest_urlpublisher.py	Fri Oct 08 07:55:11 2010 +0200
+++ b/web/test/unittest_urlpublisher.py	Fri Oct 08 11:11:08 2010 +0200
@@ -77,7 +77,7 @@
         self.assertEqual(ctrl, 'view')
         self.assertEqual(len(rset), 1)
         self.assertEqual(rset.description[0][0], 'CWUser')
-        self.assertEqual(rset.printable_rql(), 'Any X,AA,AB,AC,AD WHERE X eid 5, X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD')
+        self.assertEqual(rset.printable_rql(), 'Any X,AA,AB,AC,AD WHERE X eid %s, X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD' % rset[0][0])
         # test non-ascii paths
         ctrl, rset = self.process('CWUser/login/%C3%BFsa%C3%BFe')
         self.assertEqual(ctrl, 'view')