# -*- coding: utf-8 -*-
"""
:copyright: © 2019 by the Lin team.
:license: MIT, see LICENSE for more details.
"""
import unittest
from app.app import create_app
from flask.cli import FlaskGroup
app = create_app()
cli = FlaskGroup(app)
@cli.command('test')
def test():
"""Runs the tests without code coverage"""
tests = unittest.TestLoader().discover('app/tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
if __name__ == '__main__':
# app.run(debug=True)
cli()
这段代码如何修改为pytest自动执行多个test文件
@cli.command('test')
def test():
"""Runs the tests without code coverage"""
tests = unittest.TestLoader().discover('app/tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
问题描述
问题出现的环境背景及自己尝试过哪些方法
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
试试这样:
参考Calling pytest from Python code