add test if FieldDoesNotExist is raised
When trying to set an undefined field.
This commit is contained in:
parent
4627af3e90
commit
6d48100f44
@ -3068,6 +3068,16 @@ class FieldTest(unittest.TestCase):
|
||||
except Exception:
|
||||
self.fail()
|
||||
|
||||
def test_undefined_field_exception(self):
|
||||
"""Tests if a `FieldDoesNotExist` exception is raised when trying to
|
||||
set a value to a field that's not defined.
|
||||
"""
|
||||
|
||||
class Doc(Document):
|
||||
foo = StringField(db_field='f')
|
||||
|
||||
with self.assertRaises(FieldDoesNotExist):
|
||||
Doc(bar='test')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user