pytester: workaround issue causing spawn to crash or hang
In pytester tests, pytest stashes & restores the sys.modules for each test. So if the test imports a new module, it is initialized anew each time. Turns out the readline module isn't multi-init safe, which causes pytester.spawn to crash or hang. So preserve it as a workaround.
This commit is contained in:
parent
897f151e94
commit
ca82214444
|
@ -0,0 +1 @@
|
||||||
|
Fixed a crash or hang in ``pytester.spawn`` when the ``readline`` module is involved.
|
|
@ -707,8 +707,11 @@ class Pytester:
|
||||||
# Some zope modules used by twisted-related tests keep internal state
|
# Some zope modules used by twisted-related tests keep internal state
|
||||||
# and can't be deleted; we had some trouble in the past with
|
# and can't be deleted; we had some trouble in the past with
|
||||||
# `zope.interface` for example.
|
# `zope.interface` for example.
|
||||||
|
#
|
||||||
|
# Preserve readline due to https://bugs.python.org/issue41033.
|
||||||
|
# pexpect issues a SIGWINCH.
|
||||||
def preserve_module(name):
|
def preserve_module(name):
|
||||||
return name.startswith("zope")
|
return name.startswith(("zope", "readline"))
|
||||||
|
|
||||||
return SysModulesSnapshot(preserve=preserve_module)
|
return SysModulesSnapshot(preserve=preserve_module)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue