Skip to content

Commit 97385ca

Browse files
author
A. Jesse Jiryu Davis
committed
Fix potential race conditions in test_collection PYTHON-357
1 parent eeef917 commit 97385ca

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/test_collection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,17 +633,17 @@ def iterate():
633633

634634
def test_invalid_key_names(self):
635635
db = self.db
636-
db.test.remove({})
636+
db.test.drop()
637637

638-
db.test.insert({"hello": "world"})
639-
db.test.insert({"hello": {"hello": "world"}})
638+
db.test.insert({"hello": "world"}, safe=True)
639+
db.test.insert({"hello": {"hello": "world"}}, safe=True)
640640

641641
self.assertRaises(InvalidDocument, db.test.insert, {"$hello": "world"})
642642
self.assertRaises(InvalidDocument, db.test.insert,
643643
{"hello": {"$hello": "world"}})
644644

645-
db.test.insert({"he$llo": "world"})
646-
db.test.insert({"hello": {"hello$": "world"}})
645+
db.test.insert({"he$llo": "world"}, safe=True)
646+
db.test.insert({"hello": {"hello$": "world"}}, safe=True)
647647

648648
self.assertRaises(InvalidDocument, db.test.insert,
649649
{".hello": "world"})
@@ -666,7 +666,7 @@ def test_insert_multiple(self):
666666
doc1 = {"hello": u"world"}
667667
doc2 = {"hello": u"mike"}
668668
self.assertEqual(db.test.find().count(), 0)
669-
ids = db.test.insert([doc1, doc2])
669+
ids = db.test.insert([doc1, doc2], safe=True)
670670
self.assertEqual(db.test.find().count(), 2)
671671
self.assertEqual(doc1, db.test.find_one({"hello": u"world"}))
672672
self.assertEqual(doc2, db.test.find_one({"hello": u"mike"}))
@@ -691,7 +691,7 @@ def test_insert_multiple_with_duplicate(self):
691691
db.test.remove()
692692

693693
# No error
694-
db.test.insert([{'i': 1}] * 2)
694+
db.test.insert([{'i': 1}] * 2, safe=False)
695695
self.assertEqual(1, db.test.count())
696696

697697
self.assertRaises(

0 commit comments

Comments
 (0)