因此,我尝试为我的 Flask 应用程序编写一些测试几天,但我无法让它运行。测试通过了,但卡在“通过”上。
我克隆了 cookiecutter-flask (cookiecutter-flask),它与 pytest 一起运行 webtest (我认为)。我的conftest.py看起来与存储库 ( conftest.py )中的相同
这些是我当前的测试:
def test_app(testapp):
app = create_app(TestConfig)
res = testapp.get('/')
res.status_code == 200
Run Code Online (Sandbox Code Playgroud)
这过去了,而且还在继续。
def test_create_admin_user(db, testapp):
password = bcrypt.generate_password_hash('test')
User.create(
uid='00000000000000000000',
email='john@doe.com',
password=password,
active=1
)
user = User.query.filter_by(email='j@d.com').first()
assert user.email == 'j@d.com'
Run Code Online (Sandbox Code Playgroud)
这就是我迷失的地方,测试卡在“通过”并且没有做任何事情。当我强制中断进程时,我得到以下信息:
Traceback (most recent call last):
File "manage.py", line 68, in <module>
manager.run()
File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, …Run Code Online (Sandbox Code Playgroud)