我被指示运行以下命令并确保所有测试均通过。
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