gpt4 book ai didi

python - Flask 默认 pytest 失败

转载 作者:太空宇宙 更新时间:2023-11-03 21:02:21 24 4
gpt4 key购买 nike

我被指示运行以下命令并确保所有测试通过。

git clone https://github.com/pallets/flask
cd flask
python3 -m venv env
. env/bin/activate
pip install -e ".[dev]"
pip install pytest
python -m pytest

虽然所有测试都应该通过,但目前有 6 或 7 个测试失败。所有失败都在“tests/test_instance_config.py”中。我该怎么做才能确保所有测试都能通过?这些特定测试失败的事实是否重要?我运行的是 Ubuntu 18 LTS。

=================================== FAILURES ===================================
____________________________ test_main_module_paths ____________________________

modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_main_module_paths0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e4b6e18>

def test_main_module_paths(modules_tmpdir, purge_module):
app = modules_tmpdir.join('main_app.py')
app.write('import flask\n\napp = flask.Flask("__main__")')
purge_module('main_app')

> from main_app import app
E ModuleNotFoundError: No module named 'main_app'

tests/test_instance_config.py:32: ModuleNotFoundError
________________________ test_uninstalled_module_paths _________________________

modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_uninstalled_module_paths0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e45c378>

def test_uninstalled_module_paths(modules_tmpdir, purge_module):
app = modules_tmpdir.join('config_module_app.py').write(
'import os\n'
'import flask\n'
'here = os.path.abspath(os.path.dirname(__file__))\n'
'app = flask.Flask(__name__)\n'
)
purge_module('config_module_app')

> from config_module_app import app
E ModuleNotFoundError: No module named 'config_module_app'

tests/test_instance_config.py:46: ModuleNotFoundError
________________________ test_uninstalled_package_paths ________________________

modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_uninstalled_package_paths0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e50abf8>

def test_uninstalled_package_paths(modules_tmpdir, purge_module):
app = modules_tmpdir.mkdir('config_package_app')
init = app.join('__init__.py')
init.write(
'import os\n'
'import flask\n'
'here = os.path.abspath(os.path.dirname(__file__))\n'
'app = flask.Flask(__name__)\n'
)
purge_module('config_package_app')

> from config_package_app import app
E ModuleNotFoundError: No module named 'config_package_app'

tests/test_instance_config.py:61: ModuleNotFoundError
______________________ test_installed_module_paths[True] _______________________

modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_module_paths_Tr0/modules_tmpdir')
modules_tmpdir_prefix = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_module_paths_Tr0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e45c378>
site_packages = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_module_paths_Tr0/modules_tmpdir/lib/python3.6/site-packages')
limit_loader = None

def test_installed_module_paths(modules_tmpdir, modules_tmpdir_prefix,
purge_module, site_packages, limit_loader):
site_packages.join('site_app.py').write(
'import flask\n'
'app = flask.Flask(__name__)\n'
)
purge_module('site_app')

> from site_app import app
E ModuleNotFoundError: No module named 'site_app'

tests/test_instance_config.py:73: ModuleNotFoundError
______________________ test_installed_package_paths[True] ______________________

limit_loader = None
modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_package_paths_T0/modules_tmpdir')
modules_tmpdir_prefix = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_package_paths_T0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e48bd90>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f2c7e47d080>

def test_installed_package_paths(limit_loader, modules_tmpdir,
modules_tmpdir_prefix, purge_module,
monkeypatch):
installed_path = modules_tmpdir.mkdir('path')
monkeypatch.syspath_prepend(installed_path)

app = installed_path.mkdir('installed_package')
init = app.join('__init__.py')
init.write('import flask\napp = flask.Flask(__name__)')
purge_module('installed_package')

> from installed_package import app
E ModuleNotFoundError: No module named 'installed_package'

tests/test_instance_config.py:89: ModuleNotFoundError
_____________________ test_installed_package_paths[False] ______________________

limit_loader = None
modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_package_paths_F0/modules_tmpdir')
modules_tmpdir_prefix = local('/tmp/pytest-of-vedantroy/pytest-1/test_installed_package_paths_F0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e48bd08>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f2c7e415828>

def test_installed_package_paths(limit_loader, modules_tmpdir,
modules_tmpdir_prefix, purge_module,
monkeypatch):
installed_path = modules_tmpdir.mkdir('path')
monkeypatch.syspath_prepend(installed_path)

app = installed_path.mkdir('installed_package')
init = app.join('__init__.py')
init.write('import flask\napp = flask.Flask(__name__)')
purge_module('installed_package')

> from installed_package import app
E ModuleNotFoundError: No module named 'installed_package'

tests/test_instance_config.py:89: ModuleNotFoundError
_______________________ test_prefix_package_paths[True] ________________________

limit_loader = None
modules_tmpdir = local('/tmp/pytest-of-vedantroy/pytest-1/test_prefix_package_paths_True0/modules_tmpdir')
modules_tmpdir_prefix = local('/tmp/pytest-of-vedantroy/pytest-1/test_prefix_package_paths_True0/modules_tmpdir')
purge_module = <function purge_module.<locals>.inner at 0x7f2c7e47b488>
site_packages = local('/tmp/pytest-of-vedantroy/pytest-1/test_prefix_package_paths_True0/modules_tmpdir/lib/python3.6/site-packages')

def test_prefix_package_paths(limit_loader, modules_tmpdir,
modules_tmpdir_prefix, purge_module,
site_packages):
app = site_packages.mkdir('site_package')
init = app.join('__init__.py')
init.write('import flask\napp = flask.Flask(__name__)')
purge_module('site_package')

> import site_package
E ModuleNotFoundError: No module named 'site_package'

tests/test_instance_config.py:102: ModuleNotFoundError

最佳答案

事实证明这是 pytest 中的一个错误。 Github 问题可以在这里找到:https://github.com/pallets/flask/issues/3151

关于python - Flask 默认 pytest 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55644164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com