How to test DoesNotExist exception of MongoEngine
flask, mongodb, mongoengine, python
Solution
You are just using `assertRaises` incorrectly - function arguments should be passed alongside with the function under test:
assertRaises(DoesNotExist, Model.objects.get, id=id)
Problem
I'm using MongoEngine with Flask to develop a REST Api How can I test the exception of a DoesNotExist? If I use ``` assertRaises(DoesNotExist, Model.objects.get(id=id)) ``` python interpreter raises a NameError exception. How can I import this DoesNotExist exception? I've seen some people importing ``` from django.db.models.base import ObjectDoesNotExist ``` but I am using Flask with MongoEngine and need to know from where should I import DoesNotExist