我正在尝试为我的应用程序编写一个简单的单元测试用例,但它在第一次测试后崩溃并出现错误:
AssertionError: View function mapping is overwriting an existing endpoint function: api.users
下面是我的测试用例(我使用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
我没有发布测试,因为它没有任何作用,它总是完成第一个测试并在下一个测试中崩溃。
我试图不断地打电话,但app_context.push()
没有帮助,我尝试使用简单的单元测试,但仍然失败。 setUp
app_context.pop()
tearDown
问题可能出在哪里?我在我的应用程序中使用了蓝图和Flask-RESTful,我应该在关闭应用程序事件时手动解除绑定吗?