Commit 690c699c authored by Tres Seaver's avatar Tres Seaver

Fix Py3k namnyisms: 'fail{If,Unless}' -> 'assert{False,True}'.

parent 9509d1a6
......@@ -41,7 +41,7 @@ class TestCorruptedFS(ZODB.tests.util.TestCase):
fstest.check(self._temp)
except FormatError as msg:
mo = re.search(rx, str(msg))
self.failIf(mo is None, "unexpected error: %s" % msg)
self.assertFalse(mo is None, "unexpected error: %s" % msg)
else:
self.fail("fstest did not detect corruption")
......
......@@ -268,7 +268,7 @@ class Test_concat(OptionsTestBase, unittest.TestCase):
ofp = Faux()
bytes, sum = self._callFUT(files, ofp)
self.assertEqual(ofp._written, [x.encode() for x in 'ABC'])
self.failUnless(ofp._closed)
self.assertTrue(ofp._closed)
_marker = object()
class Test_gen_filename(OptionsTestBase, unittest.TestCase):
......@@ -460,7 +460,7 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.assertEqual(len(remaining), len(FILENAMES))
for name in FILENAMES:
fqn = os.path.join(self._repository_directory, name)
self.failUnless(os.path.isfile(fqn))
self.assertTrue(os.path.isfile(fqn))
def test_doesnt_remove_current_repozo_files(self):
FILENAMES = ['2009-12-20-10-08-03.fs',
......@@ -472,7 +472,7 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.assertEqual(len(remaining), len(FILENAMES))
for name in FILENAMES:
fqn = os.path.join(self._repository_directory, name)
self.failUnless(os.path.isfile(fqn))
self.assertTrue(os.path.isfile(fqn))
def test_removes_older_repozo_files(self):
OLDER_FULL = ['2009-12-20-00-01-03.fs',
......@@ -494,13 +494,13 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.assertEqual(len(remaining), len(CURRENT_FULL))
for name in OLDER_FULL:
fqn = os.path.join(self._repository_directory, name)
self.failIf(os.path.isfile(fqn))
self.assertFalse(os.path.isfile(fqn))
for name in DELTAS:
fqn = os.path.join(self._repository_directory, name)
self.failIf(os.path.isfile(fqn))
self.assertFalse(os.path.isfile(fqn))
for name in CURRENT_FULL:
fqn = os.path.join(self._repository_directory, name)
self.failUnless(os.path.isfile(fqn))
self.assertTrue(os.path.isfile(fqn))
def test_removes_older_repozo_files_zipped(self):
OLDER_FULL = ['2009-12-20-00-01-03.fsz',
......@@ -522,13 +522,13 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.assertEqual(len(remaining), len(CURRENT_FULL))
for name in OLDER_FULL:
fqn = os.path.join(self._repository_directory, name)
self.failIf(os.path.isfile(fqn))
self.assertFalse(os.path.isfile(fqn))
for name in DELTAS:
fqn = os.path.join(self._repository_directory, name)
self.failIf(os.path.isfile(fqn))
self.assertFalse(os.path.isfile(fqn))
for name in CURRENT_FULL:
fqn = os.path.join(self._repository_directory, name)
self.failUnless(os.path.isfile(fqn))
self.assertTrue(os.path.isfile(fqn))
class Test_do_full_backup(OptionsTestBase, unittest.TestCase):
......
......@@ -44,7 +44,7 @@ class FileStorageCorruptTests(StorageTestBase):
self._close()
# truncation the index file
self.failUnless(os.path.exists('Data.fs.index'))
self.assertTrue(os.path.exists('Data.fs.index'))
f = open('Data.fs.index', 'rb+')
f.seek(0, 2)
size = f.tell()
......@@ -60,7 +60,7 @@ class FileStorageCorruptTests(StorageTestBase):
self._close()
# truncation the index file
self.failUnless(os.path.exists('Data.fs.index'))
self.assertTrue(os.path.exists('Data.fs.index'))
size = os.stat('Data.fs.index')[stat.ST_SIZE]
f = open('Data.fs.index', 'rb+')
while f.tell() < size:
......
......@@ -220,7 +220,8 @@ class MTStorage:
for t in threads:
t.join(60)
for t in threads:
self.failIf(t.isAlive(), "thread failed to finish in 60 seconds")
self.assertFalse(t.isAlive(),
"thread failed to finish in 60 seconds")
def check2ZODBThreads(self):
db = ZODB.DB(self._storage)
......
......@@ -249,7 +249,7 @@ class TransactionalUndoStorage:
def checkTwoObjectUndoAtOnce(self):
# Convenience
eq = self.assertEqual
unless = self.failUnless
unless = self.assertTrue
p30, p31, p32, p50, p51, p52 = map(zodb_pickle,
map(MinPO,
(30, 31, 32, 50, 51, 52)))
......@@ -357,8 +357,8 @@ class TransactionalUndoStorage:
oids = self._begin_undos_vote(t, tid)
self._storage.tpc_finish(t)
eq(len(oids), 1)
self.failUnless(oid1 in oids)
self.failUnless(not oid2 in oids)
self.assertTrue(oid1 in oids)
self.assertTrue(not oid2 in oids)
data, revid1 = self._storage.load(oid1, '')
eq(zodb_unpickle(data), MinPO(33))
data, revid2 = self._storage.load(oid2, '')
......
......@@ -161,8 +161,8 @@ class ConnectionDotAdd(ZODB.tests.util.TestCase):
old_cache = self.datamgr._cache
self.datamgr._resetCache()
new_cache = self.datamgr._cache
self.failIf(new_cache is old_cache)
self.failUnless(self.datamgr._reader._cache is new_cache)
self.assertFalse(new_cache is old_cache)
self.assertTrue(self.datamgr._reader._cache is new_cache)
class UserMethodTests(unittest.TestCase):
......
......@@ -124,9 +124,9 @@ class TestPList(unittest.TestCase):
# Test __contains__
for i in u2:
self.failUnless(i in u2, "i in u2")
self.assertTrue(i in u2, "i in u2")
for i in min(u2)-1, max(u2)+1:
self.failUnless(i not in u2, "i not in u2")
self.assertTrue(i not in u2, "i not in u2")
# Test __delslice__
......@@ -142,12 +142,12 @@ class TestPList(unittest.TestCase):
# Test __add__, __radd__, __mul__ and __rmul__
#self.failUnless(u1 + [] == [] + u1 == u1, "u1 + [] == [] + u1 == u1")
self.failUnless(u1 + [1] == u2, "u1 + [1] == u2")
#self.failUnless([-1] + u1 == [-1, 0], "[-1] + u1 == [-1, 0]")
self.failUnless(u2 == u2*1 == 1*u2, "u2 == u2*1 == 1*u2")
self.failUnless(u2+u2 == u2*2 == 2*u2, "u2+u2 == u2*2 == 2*u2")
self.failUnless(u2+u2+u2 == u2*3 == 3*u2, "u2+u2+u2 == u2*3 == 3*u2")
#self.assertTrue(u1 + [] == [] + u1 == u1, "u1 + [] == [] + u1 == u1")
self.assertTrue(u1 + [1] == u2, "u1 + [1] == u2")
#self.assertTrue([-1] + u1 == [-1, 0], "[-1] + u1 == [-1, 0]")
self.assertTrue(u2 == u2*1 == 1*u2, "u2 == u2*1 == 1*u2")
self.assertTrue(u2+u2 == u2*2 == 2*u2, "u2+u2 == u2*2 == 2*u2")
self.assertTrue(u2+u2+u2 == u2*3 == 3*u2, "u2+u2+u2 == u2*3 == 3*u2")
# Test append
......
......@@ -100,7 +100,7 @@ class ZODBTests(ZODB.tests.util.TestCase):
else:
raise
else:
self.failUnless(not abort_it, 'Did not abort duplication')
self.assertTrue(not abort_it, 'Did not abort duplication')
l1 = list(ob.items())
l1.sort()
l2 = list(ob2.items())
......@@ -560,8 +560,8 @@ class ReadConflictTests(ZODB.tests.util.TestCase):
# but 3.2.3 had a bug wherein it did.
data_conflicts = data._p_jar._conflicts
data2_conflicts = data2._p_jar._conflicts
self.failIf(data_conflicts)
self.failIf(data2_conflicts) # this used to fail
self.assertFalse(data_conflicts)
self.assertFalse(data2_conflicts) # this used to fail
# And because of that, we still couldn't commit a change to data2['d']
# in the new transaction.
......
......@@ -68,7 +68,7 @@ class Test(unittest.TestCase):
self.assertEqual(index.get(key), None)
self.assertEqual(index.get(key, ''), '')
# self.failUnless(len(index._data) > 1)
# self.assertTrue(len(index._data) > 1)
def testUpdate(self):
index = self.index
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment