diff options
author | Ran Benita <ran@unusedvar.com> | 2020-10-25 03:44:04 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-10-25 16:31:47 +0200 |
commit | ca82214444b82675af0a5ef2b4696161be0e5a0c (patch) | |
tree | f7a49c2f2347852fb8e314e44a45de40c983dca7 /src | |
parent | 897f151e94ad4a16721510fbdbf935f8344aad0a (diff) | |
download | pytest-ca82214444b82675af0a5ef2b4696161be0e5a0c.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/_pytest/pytester.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index a1768363b..935be84c1 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -707,8 +707,11 @@ class Pytester: # Some zope modules used by twisted-related tests keep internal state # and can't be deleted; we had some trouble in the past with # `zope.interface` for example. + # + # Preserve readline due to https://bugs.python.org/issue41033. + # pexpect issues a SIGWINCH. def preserve_module(name): - return name.startswith("zope") + return name.startswith(("zope", "readline")) return SysModulesSnapshot(preserve=preserve_module) |