ran unittest2pytest
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user