PicklingError using live_server fixture on Windows
还没有人认领这个 Issue。
评估
调研方向
首先,在使用 Python 2.7.12 的 Windows 上复现 live_server fixture 失败的问题,然后检查 pytest_flask/plugin.py 第 85 行附近以及 pytest_flask/fixtures.py 第 64 行和第 127 行附近的代码。跟踪引发 PicklingError 的 multiprocessing 启动过程,并确定预期结果是使 live_server fixture 正常工作,还是记录 Windows 支持方面的限制。
由索引模型根据 Issue 内容生成。
描述
Not sure if Windows is supposed to be supported, but for me it fails on Windows 10 Python 2.7.12 with the following error when live_server fixture used:
request = <SubRequest '_push_request_context' for <Function 'test_get_url'>>
@pytest.fixture(autouse=True)
def _push_request_context(request):
"""During tests execution request context has been pushed, e.g. `url_for`,
`session`, etc. can be used in tests as is::
def test_app(app, client):
assert client.get(url_for('myview')).status_code == 200
"""
if 'app' not in request.fixturenames:
return
app = request.getfuncargvalue('app')
# Get application bound to the live server if ``live_server`` fixture
# is applyed. Live server application has an explicit ``SERVER_NAME``,
# so ``url_for`` function generates a complete URL for endpoint which
# includes application port as well.
if 'live_server' in request.fixturenames:
> app = request.getfuncargvalue('live_server').app
..\..\..\..\python-virtualenv\shadow\Lib\site-packages\pytest_flask\plugin.py:85:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\..\python-virtualenv\shadow\Lib\site-packages\pytest_flask\fixtures.py:127: in live_server
server.start()
..\..\..\..\python-virtualenv\shadow\Lib\site-packages\pytest_flask\fixtures.py:64: in start
self._process.start()
c:\python27\Lib\multiprocessing\process.py:130: in start
self._popen = Popen(self)
c:\python27\Lib\multiprocessing\forking.py:277: in __init__
dump(process_obj, to_child, HIGHEST_PROTOCOL)
c:\python27\Lib\multiprocessing\forking.py:199: in dump
ForkingPickler(file, protocol).dump(obj)
c:\python27\Lib\pickle.py:224: in dump
self.save(obj)
c:\python27\Lib\pickle.py:331: in save
self.save_reduce(obj=obj, *rv)
c:\python27\Lib\pickle.py:425: in save_reduce
save(state)
c:\python27\Lib\pickle.py:286: in save
f(self, obj) # Call unbound method with explicit self
c:\python27\Lib\pickle.py:655: in save_dict
self._batch_setitems(obj.iteritems())
c:\python27\Lib\pickle.py:687: in _batch_setitems
save(v)
c:\python27\Lib\pickle.py:286: in save
f(self, obj) # Call unbound method with explicit self
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <multiprocessing.forking.ForkingPickler instance at 0x0000000007EDBA08>
obj = <function <lambda> at 0x00000000081B9DD8>, name = '<lambda>'
pack = <built-in function pack>
def save_global(self, obj, name=None, pack=struct.pack):
write = self.write
memo = self.memo
if name is None:
name = obj.__name__
module = getattr(obj, "__module__", None)
if module is None:
module = whichmodule(obj, name)
try:
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
raise PicklingError(
"Can't pickle %r: it's not found as %s.%s" %
> (obj, module, name))
E PicklingError: Can't pickle <function <lambda> at 0x00000000081B9DD8>: it's not found as pytest_flask.fixtures.<lambda>
- 主要语言
- Python
- 星标
- 499
- 派生
- 93
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytest-dev/pytest-flask 的其他 Issue
-
bug
难度 3/5 1-2 天 新手友好度 35/100
pytest-dev/pytest-flask#190 · 1 条评论 · 1 个 reaction ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
pytest-dev/pytest-flask#187 · 7 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 45/100
pytest-dev/pytest-flask#175 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
pytest-dev/pytest-flask#163 · 1 条评论 · 1 个 reaction ·
-
feature request
难度 4/5 3-5 天 新手友好度 45/100
pytest-dev/pytest-flask#153 · 1 条评论 ·
查看 pytest-dev/pytest-flask 的全部 Issue
相似的 Issue
-
ACK_WAITING HELP_WANTED UPDATE_CS
难度 2/5 1-3 小时 新手友好度 78/100
OWASP/CheatSheetSeries#2458 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
BasedHardware/omi#19711 ·
维护者通常 1 天内回复
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=True未关闭
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/transformers#49172 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
vllm-project/vllm-metal#885 ·
维护者通常 1 天内回复