Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 烧瓶默认pytests失败_Python_Flask_Pytest - Fatal编程技术网

Python 烧瓶默认pytests失败

Python 烧瓶默认pytests失败,python,flask,pytest,Python,Flask,Pytest,我被指示运行以下命令并确保所有测试都通过 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\u instance\u config.py”中。如何确保所有测试都

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

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\u instance\u config.py”中。如何确保所有测试都能通过?这些特定测试失败的事实是否重要?我正在运行Ubuntu18LTS

=================================== 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
==================================================================失败===================================
____________________________测试主模块路径____________________________
模块\u tmpdir=本地('/tmp/pytest of vedantroy/pytest-1/test\u main\u模块\u路径0/modules\u tmpdir'))
清除模块=
def测试主模块路径(模块tmpdir、净化模块):
app=modules\u tmpdir.join('main\u app.py'))
app.write('import flask\n\napp=flask.flask(“\uuu main\uuuu”))
清除模块(“主应用程序”)
>从主应用程序导入应用程序
E ModuleNotFoundError:没有名为“main\u app”的模块
tests/test\u instance\u config.py:32:ModuleNotFoundError
________________________测试\u卸载的\u模块\u路径_________________________
modules_tmpdir=local('/tmp/pytest of vedantroy/pytest-1/test_unnstalled_module_paths0/modules_tmpdir'))
清除模块=
def测试\卸载\模块\路径(模块\ tmpdir、清除\模块):
app=modules\u tmpdir.join('config\u module\u app.py')。写入(
'导入操作系统\n'
'导入烧瓶\n'
'here=os.path.abspath(os.path.dirname(_文件__))\n'
'app=flask.flask(\uuuu name\uuuu)\n'
)
清除模块(“配置模块应用程序”)
>从配置模块应用导入应用
E ModuleNotFoundError:没有名为'config\u module\u app'的模块
tests/test\u instance\u config.py:46:ModuleNotFoundError
________________________测试\u卸载的\u包\u路径________________________
modules_tmpdir=local('/tmp/pytest of vedantroy/pytest-1/test_unnstalled_package_paths0/modules_tmpdir'))
清除模块=
def测试\卸载\包\路径(模块\ tmpdir、清除\模块):
app=modules\u tmpdir.mkdir('config\u package\u app'))
init=app.join(“\uuu init\uuuu.py”)
初始化写入(
'导入操作系统\n'
'导入烧瓶\n'
'here=os.path.abspath(os.path.dirname(_文件__))\n'
'app=flask.flask(\uuuu name\uuuu)\n'
)
清除模块('config\u package\u app')
>从配置\程序包\应用程序导入应用程序
E ModuleNotFoundError:没有名为'config\u package\u app'的模块
tests/test\u instance\u config.py:61:ModuleNotFoundError
______________________测试安装的模块路径[正确]_______________________
模块\u tmpdir=本地('/tmp/pytest of vedantroy/pytest-1/test\u已安装模块\u路径\u Tr0/modules\u tmpdir')
模块\u tmpdir\u前缀=本地('/tmp/pytest of vedantroy/pytest-1/test\u已安装模块\u路径\u Tr0/modules\u tmpdir')
清除模块=
site_packages=local('/tmp/pytest-of-vedantroy/pytest-1/test_-installed_-module_-path_-Tr0/modules_-tmpdir/lib/python3.6/site packages')
限制加载程序=无
def测试安装的模块路径(模块tmpdir、模块tmpdir前缀、,
清除模块、站点包、限制加载程序):
site\u包。加入('site\u app.py')。写入(
'导入烧瓶\n'
'app=flask.flask(\uuuu name\uuuu)\n'
)
清除模块(“站点应用程序”)
>从站点\应用程序导入应用程序
E ModuleNotFoundError:没有名为“site\u app”的模块
tests/test\u instance\u config.py:73:ModuleNotFoundError
______________________测试\u安装的\u程序包\u路径[正确]______________________
限制加载程序=无
模块\u tmpdir=本地('/tmp/pytest of vedantroy/pytest-1/test\u已安装\u程序包\u路径\u T0/modules\u tmpdir')
模块\u tmpdir \u前缀=本地('/tmp/pytest of vedantroy/pytest-1/test\u已安装\u程序包\u路径\u T0/modules\u tmpdir')
清除模块=
monkeypatch=
def测试安装路径(限制加载程序、模块、tmpdir、,
模块\u tmpdir\u前缀,清除\u模块,
monkeypatch):
已安装的\u path=modules\u tmpdir.mkdir('path'))
monkeypatch.syspath\u prepend(已安装路径)
app=installed_path.mkdir('installed_package')
init=app.join(“\uuu init\uuuu.py”)
init.write('import flask\napp=flask.flask(\uuuu name\uuuuuu'))
清除\u模块(“已安装的\u包”)
>从已安装的软件包导入应用程序
E ModuleNotFoundError:没有名为“installed\u package”的模块
tests/test\u instance\u config.py:89:ModuleNotFoundError
_____________________测试安装的包路径[错误]______________________
限制加载程序=无
模块\u tmpdir=本地('/tmp/pytest of vedantroy/pytest-1/test_已安装\u程序包\u路径\u F0/模块\u tmpdir')
模块\u tmpdir\u前缀=本地('/tmp/pytest of vedantroy/pytest-1/test\u已安装\u程序包\u路径\u F0/modules\u tmpdir')
清除模块=
monkeypatch=
def测试安装路径(限制加载程序、模块、tmpdir、,
模块\u tmpdir\u前缀,清除\u模块,
monkeypatch):
已安装的\u path=modules\u tmpdir.mkdir('path'))
monkeypatch.syspath\u prepend(已安装路径)
app=installed_path.mkdir('installed_package')
init=app.join(“\uuu init\uuuu.py”)
init.write('import flask\napp=flask.flask(\uuuu name\uuuuuu'))
清除\u模块(“已安装的\u包”)
>从已安装的软件包导入应用程序
E ModuleNotFoundError:没有名为“installed\u package”的模块
tests/test\u instance\u config.py:89:ModuleNotFoundError
_______________________测试\前缀\包\路径[真]________________________
限制加载程序=无
modules_tmpdir=local('/tmp/pytest of vedantroy/pytest-1/test_prefix_package_path_True0/modules_tmpdir'))
modules_tmpdir_prefix=local('/tmp/pytest of vedantroy/pytest-1/test_prefix_package_path_True0/modules_tmpdir'))
清除模块=
site_packages=local(“/tmp/pytest of vedantroy/pytest-1/test_前缀_package_路径_True0/modules_tmpdir/lib/python3.6/site packages”)
def测试前缀包路径(限制权限)