ran unittest2pytest

This commit is contained in:
Bastien Gérard
2019-08-30 16:13:30 +03:00
parent aa6ff8c84a
commit ac25f4b98b
46 changed files with 4247 additions and 4428 deletions

View File

@@ -2,6 +2,7 @@
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
import pytest
class TestBooleanField(MongoDBTestCase):
@@ -11,7 +12,7 @@ class TestBooleanField(MongoDBTestCase):
person = Person(admin=True)
person.save()
self.assertEqual(get_as_pymongo(person), {"_id": person.id, "admin": True})
assert get_as_pymongo(person) == {"_id": person.id, "admin": True}
def test_validation(self):
"""Ensure that invalid values cannot be assigned to boolean
@@ -26,11 +27,14 @@ class TestBooleanField(MongoDBTestCase):
person.validate()
person.admin = 2
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
person.admin = "Yes"
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
person.admin = "False"
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
def test_weirdness_constructor(self):
"""When attribute is set in contructor, it gets cast into a bool
@@ -42,7 +46,7 @@ class TestBooleanField(MongoDBTestCase):
admin = BooleanField()
new_person = Person(admin="False")
self.assertTrue(new_person.admin)
assert new_person.admin
new_person = Person(admin="0")
self.assertTrue(new_person.admin)
assert new_person.admin