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

@@ -4,6 +4,7 @@ import six
from mongoengine import *
from tests.utils import MongoDBTestCase
import pytest
class TestFloatField(MongoDBTestCase):
@@ -16,8 +17,8 @@ class TestFloatField(MongoDBTestCase):
TestDocument(float_fld=None).save()
TestDocument(float_fld=1).save()
self.assertEqual(1, TestDocument.objects(float_fld__ne=None).count())
self.assertEqual(1, TestDocument.objects(float_fld__ne=1).count())
assert 1 == TestDocument.objects(float_fld__ne=None).count()
assert 1 == TestDocument.objects(float_fld__ne=1).count()
def test_validation(self):
"""Ensure that invalid values cannot be assigned to float fields.
@@ -34,16 +35,20 @@ class TestFloatField(MongoDBTestCase):
person.validate()
person.height = "2.0"
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
person.height = 0.01
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
person.height = 4.0
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
person_2 = Person(height="something invalid")
self.assertRaises(ValidationError, person_2.validate)
with pytest.raises(ValidationError):
person_2.validate()
big_person = BigPerson()
@@ -55,4 +60,5 @@ class TestFloatField(MongoDBTestCase):
big_person.validate()
big_person.height = 2 ** 100000 # Too big for a float value
self.assertRaises(ValidationError, big_person.validate)
with pytest.raises(ValidationError):
big_person.validate()