3

I am trying to write a simple unittest case for my app but it crashes after the first test with error:

AssertionError: View function mapping is overwriting an existing endpoint function: api.users

Below is my test case (I use Flask-Testing):

class RestApiTestCase(TestCase):

    def create_app(self):
        app = create_app('config.testing')
        self.client = app.test_client()
        return app

    def setUp(self):
        self.db = DAO(db)
        init_db(db)

    def tearDown(self):
        db.session.remove()
        drop_db(db)
        self.db = None

I didn't post tests because of it doesn't play any role, it always completes the first test and crashes on the next.
I tried to call app_context.push() on setUp and app_context.pop() on tearDown but it didn't help, I tried to use simple unittest and it still fails.

Where can problem be? I use blueprint and Flask-RESTful in my app, should I unbind it manually on shutting down app event?

Denis Sologub
  • 7,277
  • 11
  • 56
  • 123

0 Answers0