Skip to content

Commit

Permalink
Modern unittest idioms imported from Python core.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaering committed Mar 4, 2010
1 parent bc28a4c commit 68a5623
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/test/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ def CheckSqliteRowHashCmp(self):
self.assertTrue(row_1 == row_2)
self.assertTrue(row_2 != row_3)

self.failIf(row_1 != row_1)
self.failIf(row_1 != row_2)
self.failIf(row_2 == row_3)
self.assertFalse(row_1 != row_1)
self.assertFalse(row_1 != row_2)
self.assertFalse(row_2 == row_3)

self.assertEqual(row_1, row_2)
self.assertEqual(hash(row_1), hash(row_2))
self.failIfEqual(row_1, row_3)
self.failIfEqual(hash(row_1), hash(row_3))
self.assertNotEqual(row_1, row_3)
self.assertNotEqual(hash(row_1), hash(row_3))

def tearDown(self):
self.con.close()
Expand Down
6 changes: 3 additions & 3 deletions lib/test/py25/py25tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ def CheckContextManagerCommit(self):
self.con.execute("insert into test(c) values ('foo')")
self.con.rollback()
count = self.con.execute("select count(*) from test").fetchone()[0]
self.failUnlessEqual(count, 1)
self.assertEqual(count, 1)

def CheckContextManagerRollback(self):
"""Is a rollback called in the context manager?"""
global did_rollback
self.failUnlessEqual(did_rollback, False)
self.assertEqual(did_rollback, False)
try:
with self.con:
self.con.execute("insert into test(c) values (4)")
self.con.execute("insert into test(c) values (4)")
except sqlite.IntegrityError:
pass
self.failUnlessEqual(did_rollback, True)
self.assertEqual(did_rollback, True)

def suite():
ctx_suite = unittest.makeSuite(ContextTests, "Check")
Expand Down
4 changes: 3 additions & 1 deletion lib/test/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.

import zlib, datetime
import datetime
import unittest
import pysqlite2.dbapi2 as sqlite
import zlib


class SqliteTypeTests(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 68a5623

Please sign in to comment.