Skip to content

Commit

Permalink
Fix Py3k namnyisms: 'fail{If,Unless}' -> 'assert{False,True}'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Feb 15, 2013
1 parent 9509d1a commit 690c699
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/ZODB/scripts/manual_tests/testfstest.py
Expand Up @@ -41,7 +41,7 @@ def detectsError(self, rx):
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")

Expand Down
18 changes: 9 additions & 9 deletions src/ZODB/scripts/tests/test_repozo.py
Expand Up @@ -268,7 +268,7 @@ def close(self):
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):
Expand Down Expand Up @@ -460,7 +460,7 @@ def test_no_repozo_files_doesnt_raise(self):
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',
Expand All @@ -472,7 +472,7 @@ def test_doesnt_remove_current_repozo_files(self):
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',
Expand All @@ -494,13 +494,13 @@ def test_removes_older_repozo_files(self):
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',
Expand All @@ -522,13 +522,13 @@ def test_removes_older_repozo_files_zipped(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions src/ZODB/tests/Corruption.py
Expand Up @@ -44,7 +44,7 @@ def checkTruncatedIndex(self):
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()
Expand All @@ -60,7 +60,7 @@ def checkCorruptedIndex(self):
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:
Expand Down
3 changes: 2 additions & 1 deletion src/ZODB/tests/MTStorage.py
Expand Up @@ -220,7 +220,8 @@ def _checkNThreads(self, n, constructor, *args):
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)
Expand Down
6 changes: 3 additions & 3 deletions src/ZODB/tests/TransactionalUndoStorage.py
Expand Up @@ -249,7 +249,7 @@ def checkTwoObjectUndo(self):
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)))
Expand Down Expand Up @@ -357,8 +357,8 @@ def checkTwoObjectUndoAgain(self):
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, '')
Expand Down
4 changes: 2 additions & 2 deletions src/ZODB/tests/testConnection.py
Expand Up @@ -161,8 +161,8 @@ def check__resetCacheResetsReader(self):
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):

Expand Down
16 changes: 8 additions & 8 deletions src/ZODB/tests/testPersistentList.py
Expand Up @@ -124,9 +124,9 @@ def mycmp(a, b):

# 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__

Expand All @@ -142,12 +142,12 @@ def mycmp(a, b):

# 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

Expand Down
6 changes: 3 additions & 3 deletions src/ZODB/tests/testZODB.py
Expand Up @@ -100,7 +100,7 @@ def verify(self, conn, abort_it):
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())
Expand Down Expand Up @@ -560,8 +560,8 @@ def checkReadConflictErrorClearedDuringAbort(self):
# 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.
Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/tests/testfsIndex.py
Expand Up @@ -68,7 +68,7 @@ def testInserts(self):
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
Expand Down

0 comments on commit 690c699

Please sign in to comment.