Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions Lib/test/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import errno
import weakref
import test.script_helper
from test import test_support
from test import support
from StringIO import StringIO
_multiprocessing = test_support.import_module('_multiprocessing')
_multiprocessing = support.import_module('_multiprocessing')
# import threading after _multiprocessing to raise a more relevant error
# message: "No module named _multiprocessing". _multiprocessing is not compiled
# without thread support.
import threading

# Work around broken sem_open implementations
test_support.import_module('multiprocessing.synchronize')
support.import_module('multiprocessing.synchronize')

import multiprocessing.dummy
import multiprocessing.connection
Expand Down Expand Up @@ -341,8 +341,8 @@ def test_sys_exit(self):
if self.TYPE == 'threads':
self.skipTest('test not appropriate for {}'.format(self.TYPE))

testfn = test_support.TESTFN
self.addCleanup(test_support.unlink, testfn)
testfn = support.TESTFN
self.addCleanup(support.unlink, testfn)

for reason, code in (([1, 2, 3], 1), ('ignore this', 1)):
p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
Expand Down Expand Up @@ -640,7 +640,7 @@ def test_task_done(self):
p.join()

def test_no_import_lock_contention(self):
with test_support.temp_cwd():
with support.temp_cwd():
module_name = 'imported_by_an_imported_module'
with open(module_name + '.py', 'w') as f:
f.write("""if 1:
Expand All @@ -652,7 +652,7 @@ def test_no_import_lock_contention(self):
q.close()
""")

with test_support.DirsOnSysPath(os.getcwd()):
with support.DirsOnSysPath(os.getcwd()):
try:
__import__(module_name)
except Queue.Empty:
Expand Down Expand Up @@ -1517,10 +1517,10 @@ class _TestRemoteManager(BaseTestCase):
#'hall\xc3\xa5 v\xc3\xa4rlden'] # UTF-8
]
result = values[:]
if test_support.have_unicode:
if support.have_unicode:
#result[-1] = u'hall\xe5 v\xe4rlden'
uvalue = test_support.u(r'\u043f\u0440\u0438\u0432\u0456\u0442 '
r'\u0441\u0432\u0456\u0442')
uvalue = support.u(r'\u043f\u0440\u0438\u0432\u0456\u0442 '
r'\u0441\u0432\u0456\u0442')
values.append(uvalue)
result.append(uvalue)

Expand All @@ -1538,7 +1538,7 @@ def test_remote(self):
authkey = os.urandom(32)

manager = QueueManager(
address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER
address=(test.support.HOST, 0), authkey=authkey, serializer=SERIALIZER
)
manager.start()

Expand Down Expand Up @@ -1575,7 +1575,7 @@ def _putter(cls, address, authkey):
def test_rapid_restart(self):
authkey = os.urandom(32)
manager = QueueManager(
address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER)
address=(test.support.HOST, 0), authkey=authkey, serializer=SERIALIZER)
srvr = manager.get_server()
addr = srvr.address
# Close the connection.Listener socket which gets opened as a part
Expand Down Expand Up @@ -1786,13 +1786,13 @@ def test_fd_transfer(self):
p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
p.daemon = True
p.start()
with open(test_support.TESTFN, "wb") as f:
with open(support.TESTFN, "wb") as f:
fd = f.fileno()
if msvcrt:
fd = msvcrt.get_osfhandle(fd)
reduction.send_handle(conn, fd, p.pid)
p.join()
with open(test_support.TESTFN, "rb") as f:
with open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"foo")

@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
Expand All @@ -1811,7 +1811,7 @@ def test_large_fd_transfer(self):
p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
p.daemon = True
p.start()
with open(test_support.TESTFN, "wb") as f:
with open(support.TESTFN, "wb") as f:
fd = f.fileno()
for newfd in range(256, MAXFD):
if not self._is_fd_assigned(newfd):
Expand All @@ -1824,7 +1824,7 @@ def test_large_fd_transfer(self):
finally:
os.close(newfd)
p.join()
with open(test_support.TESTFN, "rb") as f:
with open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"bar")

@classmethod
Expand Down Expand Up @@ -2207,7 +2207,7 @@ def make_finalizers():
gc.set_threshold(5, 5, 5)
threads = [threading.Thread(target=run_finalizers),
threading.Thread(target=make_finalizers)]
with test_support.start_threads(threads):
with support.start_threads(threads):
time.sleep(4.0) # Wait a bit to trigger race condition
finish = True
if exc:
Expand Down Expand Up @@ -2635,7 +2635,7 @@ def run_in_child(cls):
flags = (tuple(sys.flags), grandchild_flags)
print(json.dumps(flags))

@test_support.requires_unicode # XXX json needs unicode support
@support.requires_unicode # XXX json needs unicode support
def test_flags(self):
import json, subprocess
# start child process using unusual flags
Expand Down Expand Up @@ -2681,6 +2681,9 @@ def test_lock(self):

class TestIgnoreEINTR(unittest.TestCase):

# Sending CONN_MAX_SIZE bytes into a multiprocessing pipe must block
CONN_MAX_SIZE = max(support.PIPE_MAX_SIZE, support.SOCK_MAX_SIZE)

@classmethod
def _test_ignore(cls, conn):
def handler(signum, frame):
Expand All @@ -2689,7 +2692,7 @@ def handler(signum, frame):
conn.send('ready')
x = conn.recv()
conn.send(x)
conn.send_bytes(b'x' * test_support.PIPE_MAX_SIZE)
conn.send_bytes(b'x' * cls.CONN_MAX_SIZE)

@unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1')
def test_ignore(self):
Expand All @@ -2708,8 +2711,7 @@ def test_ignore(self):
self.assertEqual(conn.recv(), 1234)
time.sleep(0.1)
os.kill(p.pid, signal.SIGUSR1)
self.assertEqual(conn.recv_bytes(),
b'x' * test_support.PIPE_MAX_SIZE)
self.assertEqual(conn.recv_bytes(), b'x' * self.CONN_MAX_SIZE)
time.sleep(0.1)
p.join()
finally:
Expand Down Expand Up @@ -2766,7 +2768,7 @@ def test_main(run=None):
check_enough_semaphores()

if run is None:
from test.test_support import run_unittest as run
from test.support import run_unittest as run

util.get_temp_dir() # creates temp directory for use by all processes

Expand All @@ -2791,7 +2793,7 @@ def test_main(run=None):
# module during these tests is at least platform dependent and possibly
# non-deterministic on any given platform. So we don't mind if the listed
# warnings aren't actually raised.
with test_support.check_py3k_warnings(
with support.check_py3k_warnings(
(".+__(get|set)slice__ has been removed", DeprecationWarning),
(r"sys.exc_clear\(\) not supported", DeprecationWarning),
quiet=True):
Expand Down