tests: fix py2.7

This commit is contained in:
Casper da Costa-Luis 2021-01-09 03:19:25 +00:00
parent 4328762e54
commit 839e672748
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 4 additions and 3 deletions

View File

@ -800,12 +800,13 @@ def test_smoothed_dynamic_min_iters_with_min_interval():
@mark.slow @mark.slow
def test_rlock_creation(): def test_rlock_creation():
"""Test that importing tqdm does not create multiprocessing objects.""" """Test that importing tqdm does not create multiprocessing objects."""
importorskip('multiprocessing') mp = importorskip('multiprocessing')
from multiprocessing import get_context if not hasattr(mp, 'get_context'):
skip("missing multiprocessing.get_context")
# Use 'spawn' instead of 'fork' so that the process does not inherit any # Use 'spawn' instead of 'fork' so that the process does not inherit any
# globals that have been constructed by running other tests # globals that have been constructed by running other tests
ctx = get_context('spawn') ctx = mp.get_context('spawn')
with ctx.Pool(1) as pool: with ctx.Pool(1) as pool:
# The pool will propagate the error if the target method fails # The pool will propagate the error if the target method fails
pool.apply(_rlock_creation_target) pool.apply(_rlock_creation_target)