Ensure meta.strict does not bypass constructor check
This commit is contained in:
@@ -3171,6 +3171,21 @@ class FieldTest(unittest.TestCase):
|
||||
|
||||
self.assertRaises(FieldDoesNotExist, test)
|
||||
|
||||
def test_undefined_field_exception_with_strict(self):
|
||||
"""Tests if a `FieldDoesNotExist` exception is raised when trying to
|
||||
instanciate a document with a field that's not defined,
|
||||
even when strict is set to False.
|
||||
"""
|
||||
|
||||
class Doc(Document):
|
||||
foo = StringField(db_field='f')
|
||||
meta = {'strict': False}
|
||||
|
||||
def test():
|
||||
Doc(bar='test')
|
||||
|
||||
self.assertRaises(FieldDoesNotExist, test)
|
||||
|
||||
|
||||
class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user