s/failIf/assertFalse

This commit is contained in:
jbergstroem 2010-08-08 05:26:40 +08:00 committed by Mike Dirolf
parent 529c4897f5
commit ec22172030
8 changed files with 44 additions and 44 deletions

View File

@ -32,7 +32,7 @@ class TestBinary(unittest.TestCase):
self.assert_(a_binary.startswith("hello"))
self.assert_(a_binary.endswith("world"))
self.assert_(isinstance(a_binary, Binary))
self.failIf(isinstance(a_string, Binary))
self.assertFalse(isinstance(a_string, Binary))
def test_exceptions(self):
self.assertRaises(TypeError, Binary, None)

View File

@ -54,15 +54,15 @@ class TestBSON(unittest.TestCase):
self.assertRaises(TypeError, is_valid, u"test")
self.assertRaises(TypeError, is_valid, 10.4)
self.failIf(is_valid("test"))
self.assertFalse(is_valid("test"))
# the simplest valid BSON document
self.assert_(is_valid("\x05\x00\x00\x00\x00"))
self.assert_(is_valid(BSON("\x05\x00\x00\x00\x00")))
self.failIf(is_valid("\x04\x00\x00\x00\x00"))
self.failIf(is_valid("\x05\x00\x00\x00\x01"))
self.failIf(is_valid("\x05\x00\x00\x00"))
self.failIf(is_valid("\x05\x00\x00\x00\x00\x00"))
self.assertFalse(is_valid("\x04\x00\x00\x00\x00"))
self.assertFalse(is_valid("\x05\x00\x00\x00\x01"))
self.assertFalse(is_valid("\x05\x00\x00\x00"))
self.assertFalse(is_valid("\x05\x00\x00\x00\x00\x00"))
def test_random_data_is_not_bson(self):
qcheck.check_unittest(self, qcheck.isnt(is_valid),
@ -293,7 +293,7 @@ class TestBSON(unittest.TestCase):
def test_custom_class(self):
self.assert_(isinstance(BSON.from_dict({}).to_dict(), dict))
self.failIf(isinstance(BSON.from_dict({}).to_dict(), SON))
self.assertFalse(isinstance(BSON.from_dict({}).to_dict(), SON))
self.assert_(isinstance(BSON.from_dict({}).to_dict(SON), SON))
self.assertEqual(1, BSON.from_dict({"x": 1}).to_dict(SON)["x"])

View File

@ -49,7 +49,7 @@ class TestCode(unittest.TestCase):
self.assert_(a_code.startswith("hello"))
self.assert_(a_code.endswith("world"))
self.assert_(isinstance(a_code, Code))
self.failIf(isinstance(a_string, Code))
self.assertFalse(isinstance(a_string, Code))
self.assertEqual(a_code.scope, {})
a_code.scope["my_var"] = 5
self.assertEqual(a_code.scope, {"my_var": 5})

View File

@ -333,10 +333,10 @@ class TestCollection(unittest.TestCase):
self.assert_("extra thing" in db.test.find({}).next())
self.assert_("x" in db.test.find({}, ["x", "mike"]).next())
self.assert_("mike" in db.test.find({}, ["x", "mike"]).next())
self.failIf("extra thing" in db.test.find({}, ["x", "mike"]).next())
self.failIf("x" in db.test.find({}, ["mike"]).next())
self.assertFalse("extra thing" in db.test.find({}, ["x", "mike"]).next())
self.assertFalse("x" in db.test.find({}, ["mike"]).next())
self.assert_("mike" in db.test.find({}, ["mike"]).next())
self.failIf("extra thing" in db.test.find({}, ["mike"]).next())
self.assertFalse("extra thing" in db.test.find({}, ["mike"]).next())
def test_fields_specifier_as_dict(self):
db = self.db
@ -481,7 +481,7 @@ class TestCollection(unittest.TestCase):
db.test.save({"hello": "world"})
db.test.save({"hello": "mike"})
db.test.save({"hello": "world"})
self.failIf(db.error())
self.assertFalse(db.error())
db.drop_collection("test")
db.test.create_index("hello", unique=True)
@ -530,7 +530,7 @@ class TestCollection(unittest.TestCase):
db.test.insert({"hello": {"a": 4, "b": 5}})
db.test.insert({"hello": {"a": 7, "b": 2}})
db.test.insert({"hello": {"a": 4, "b": 10}})
self.failIf(db.error())
self.assertFalse(db.error())
db.drop_collection("test")
db.test.create_index("hello.a", unique=True)
@ -876,7 +876,7 @@ class TestCollection(unittest.TestCase):
db.test.save({"_id": 5})
self.assert_(db.test.find_one(5))
self.failIf(db.test.find_one(6))
self.assertFalse(db.test.find_one(6))
def test_remove_non_objectid(self):
db = self.db
@ -1062,11 +1062,11 @@ class TestCollection(unittest.TestCase):
c.insert({"x": 1})
self.assert_(isinstance(c.find().next(), dict))
self.failIf(isinstance(c.find().next(), SON))
self.assertFalse(isinstance(c.find().next(), SON))
self.assert_(isinstance(c.find(as_class=SON).next(), SON))
self.assert_(isinstance(c.find_one(), dict))
self.failIf(isinstance(c.find_one(), SON))
self.assertFalse(isinstance(c.find_one(), SON))
self.assert_(isinstance(c.find_one(as_class=SON), SON))
self.assertEqual(1, c.find_one(as_class=SON)["x"])

View File

@ -155,8 +155,8 @@ class TestConnection(unittest.TestCase):
c.pymongo_test.test.insert({"foo": "bar"})
self.failIf("pymongo_test1" in c.database_names())
self.failIf("pymongo_test2" in c.database_names())
self.assertFalse("pymongo_test1" in c.database_names())
self.assertFalse("pymongo_test2" in c.database_names())
c.copy_database("pymongo_test", "pymongo_test1")
@ -178,12 +178,12 @@ class TestConnection(unittest.TestCase):
self.assertRaises(OperationFailure, c.copy_database,
"pymongo_test", "pymongo_test1",
username="foo", password="bar")
self.failIf("pymongo_test1" in c.database_names())
self.assertFalse("pymongo_test1" in c.database_names())
self.assertRaises(OperationFailure, c.copy_database,
"pymongo_test", "pymongo_test1",
username="mike", password="bar")
self.failIf("pymongo_test1" in c.database_names())
self.assertFalse("pymongo_test1" in c.database_names())
c.copy_database("pymongo_test", "pymongo_test1",
username="mike", password="password")
@ -374,26 +374,26 @@ class TestConnection(unittest.TestCase):
self.assertEqual(dict, c.document_class)
self.assert_(isinstance(db.test.find_one(), dict))
self.failIf(isinstance(db.test.find_one(), SON))
self.assertFalse(isinstance(db.test.find_one(), SON))
c.document_class = SON
self.assertEqual(SON, c.document_class)
self.assert_(isinstance(db.test.find_one(), SON))
self.failIf(isinstance(db.test.find_one(as_class=dict), SON))
self.assertFalse(isinstance(db.test.find_one(as_class=dict), SON))
c = Connection(self.host, self.port, document_class=SON)
db = c.pymongo_test
self.assertEqual(SON, c.document_class)
self.assert_(isinstance(db.test.find_one(), SON))
self.failIf(isinstance(db.test.find_one(as_class=dict), SON))
self.assertFalse(isinstance(db.test.find_one(as_class=dict), SON))
c.document_class = dict
self.assertEqual(dict, c.document_class)
self.assert_(isinstance(db.test.find_one(), dict))
self.failIf(isinstance(db.test.find_one(), SON))
self.assertFalse(isinstance(db.test.find_one(), SON))
def test_network_timeout(self):
no_timeout = Connection(self.host, self.port)

View File

@ -112,22 +112,22 @@ class TestDatabase(unittest.TestCase):
db.test.save({"dummy": u"object"})
self.assert_("test" in db.collection_names())
db.drop_collection("test")
self.failIf("test" in db.collection_names())
self.assertFalse("test" in db.collection_names())
db.test.save({"dummy": u"object"})
self.assert_("test" in db.collection_names())
db.drop_collection(u"test")
self.failIf("test" in db.collection_names())
self.assertFalse("test" in db.collection_names())
db.test.save({"dummy": u"object"})
self.assert_("test" in db.collection_names())
db.drop_collection(db.test)
self.failIf("test" in db.collection_names())
self.assertFalse("test" in db.collection_names())
db.test.save({"dummy": u"object"})
self.assert_("test" in db.collection_names())
db.test.drop()
self.failIf("test" in db.collection_names())
self.assertFalse("test" in db.collection_names())
db.test.drop()
db.drop_collection(db.test.doesnotexist)
@ -232,7 +232,7 @@ class TestDatabase(unittest.TestCase):
self.assert_(db.last_status()["updatedExisting"])
db.test.update({"i": 1}, {"$set": {"i": 500}})
self.failIf(db.last_status()["updatedExisting"])
self.assertFalse(db.last_status()["updatedExisting"])
def test_password_digest(self):
self.assertRaises(TypeError, helpers._password_digest, 5)
@ -257,20 +257,20 @@ class TestDatabase(unittest.TestCase):
self.assertRaises(TypeError, db.authenticate, 5, "password")
self.assertRaises(TypeError, db.authenticate, "mike", 5)
self.failIf(db.authenticate("mike", "not a real password"))
self.failIf(db.authenticate("faker", "password"))
self.assertFalse(db.authenticate("mike", "not a real password"))
self.assertFalse(db.authenticate("faker", "password"))
self.assert_(db.authenticate("mike", "password"))
self.assert_(db.authenticate(u"mike", u"password"))
db.remove_user("mike")
self.failIf(db.authenticate("mike", "password"))
self.assertFalse(db.authenticate("mike", "password"))
self.failIf(db.authenticate("Gustave", u"Dor\xe9"))
self.assertFalse(db.authenticate("Gustave", u"Dor\xe9"))
db.add_user("Gustave", u"Dor\xe9")
self.assert_(db.authenticate("Gustave", u"Dor\xe9"))
db.add_user("Gustave", "password")
self.failIf(db.authenticate("Gustave", u"Dor\xe9"))
self.assertFalse(db.authenticate("Gustave", u"Dor\xe9"))
self.assert_(db.authenticate("Gustave", u"password"))
# just make sure there are no exceptions here
@ -397,11 +397,11 @@ class TestDatabase(unittest.TestCase):
self.assert_(db.test.find_one({"x": 2}))
db.test.remove({"x": 2})
self.failIf(db.test.find_one({"x": 2}))
self.assertFalse(db.test.find_one({"x": 2}))
self.assert_(db.test.find_one())
db.test.remove({})
self.failIf(db.test.find_one())
self.assertFalse(db.test.find_one())
def test_save_a_bunch(self):
db = self.connection.pymongo_test

View File

@ -193,8 +193,8 @@ class TestGridfs(unittest.TestCase):
self.assert_(self.fs.exists({"_id": oid}))
self.assert_(self.fs.exists(_id=oid))
self.failIf(self.fs.exists(filename="mike"))
self.failIf(self.fs.exists("mike"))
self.assertFalse(self.fs.exists(filename="mike"))
self.assertFalse(self.fs.exists("mike"))
oid = self.fs.put("hello", filename="mike", foo=12)
self.assert_(self.fs.exists(oid))
@ -207,10 +207,10 @@ class TestGridfs(unittest.TestCase):
self.assert_(self.fs.exists(foo={"$gt": 11}))
self.assert_(self.fs.exists({"foo": {"$gt": 11}}))
self.failIf(self.fs.exists(foo=13))
self.failIf(self.fs.exists({"foo": 13}))
self.failIf(self.fs.exists(foo={"$gt": 12}))
self.failIf(self.fs.exists({"foo": {"$gt": 12}}))
self.assertFalse(self.fs.exists(foo=13))
self.assertFalse(self.fs.exists({"foo": 13}))
self.assertFalse(self.fs.exists(foo={"$gt": 12}))
self.assertFalse(self.fs.exists({"foo": {"$gt": 12}}))
if __name__ == "__main__":

View File

@ -131,7 +131,7 @@ class TestMasterSlaveConnection(unittest.TestCase):
except:
count += 1
self.connection.end_request()
self.failIf(count)
self.assertFalse(count)
# This was failing because commands were being sent to the slaves
def test_create_collection(self):
@ -178,7 +178,7 @@ class TestMasterSlaveConnection(unittest.TestCase):
count += 1
except:
count += 1
self.failIf(count)
self.assertFalse(count)
def test_kill_cursors(self):