Commit ca16b43f authored by Jason Madden's avatar Jason Madden

Update tests for 3.5.3

Fixes #943.
parent de2d6507
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
1.2.2 (unreleased) 1.2.2 (unreleased)
================== ==================
- TBD - Testing on Python 3.5 now uses Python 3.5.3 due to SSL changes. See
:issue:`943`.
1.2.1 (2017-01-12) 1.2.1 (2017-01-12)
================== ==================
......
...@@ -107,7 +107,7 @@ BUILD_RUNTIMES?=$(PWD)/.runtimes ...@@ -107,7 +107,7 @@ BUILD_RUNTIMES?=$(PWD)/.runtimes
PY278=$(BUILD_RUNTIMES)/snakepit/python2.7.8 PY278=$(BUILD_RUNTIMES)/snakepit/python2.7.8
PY27=$(BUILD_RUNTIMES)/snakepit/python2.7.13 PY27=$(BUILD_RUNTIMES)/snakepit/python2.7.13
PY34=$(BUILD_RUNTIMES)/snakepit/python3.4.5 PY34=$(BUILD_RUNTIMES)/snakepit/python3.4.5
PY35=$(BUILD_RUNTIMES)/snakepit/python3.5.2 PY35=$(BUILD_RUNTIMES)/snakepit/python3.5.3
PY36=$(BUILD_RUNTIMES)/snakepit/python3.6.0 PY36=$(BUILD_RUNTIMES)/snakepit/python3.6.0
PYPY=$(BUILD_RUNTIMES)/snakepit/pypy56 PYPY=$(BUILD_RUNTIMES)/snakepit/pypy56
PYPY3=$(BUILD_RUNTIMES)/snakepit/pypy3.3_5.5 PYPY3=$(BUILD_RUNTIMES)/snakepit/pypy3.3_5.5
...@@ -172,7 +172,7 @@ test-py34: $(PY34) ...@@ -172,7 +172,7 @@ test-py34: $(PY34)
PYTHON=python3.4.5 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.4.5/bin:$(PATH) make develop toxtest PYTHON=python3.4.5 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.4.5/bin:$(PATH) make develop toxtest
test-py35: $(PY35) test-py35: $(PY35)
PYTHON=python3.5.2 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.5.2/bin:$(PATH) make develop fulltoxtest PYTHON=python3.5.3 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.5.3/bin:$(PATH) make develop fulltoxtest
test-py36: $(PY36) test-py36: $(PY36)
PYTHON=python3.6.0 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.6.0/bin:$(PATH) make develop toxtest PYTHON=python3.6.0 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.6.0/bin:$(PATH) make develop toxtest
...@@ -184,9 +184,9 @@ test-pypy3: $(PYPY3) ...@@ -184,9 +184,9 @@ test-pypy3: $(PYPY3)
PYTHON=$(PYPY3) PIP=pip PATH=$(BUILD_RUNTIMES)/versions/pypy3.3_5.5/bin:$(PATH) make develop toxtest PYTHON=$(PYPY3) PIP=pip PATH=$(BUILD_RUNTIMES)/versions/pypy3.3_5.5/bin:$(PATH) make develop toxtest
test-py27-cffi: $(PY27) test-py27-cffi: $(PY27)
GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop toxtest GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7.13 PATH=$(BUILD_RUNTIMES)/versions/python2.7.13/bin:$(PATH) make develop toxtest
test-py27-noembed: $(PY27) test-py27-noembed: $(PY27)
cd deps/libev && ./configure --disable-dependency-tracking && make cd deps/libev && ./configure --disable-dependency-tracking && make
cd deps/c-ares && ./configure --disable-dependency-tracking && make cd deps/c-ares && ./configure --disable-dependency-tracking && make
CPPFLAGS="-Ideps/libev -Ideps/c-ares" LDFLAGS="-Ldeps/libev/.libs -Ldeps/c-ares/.libs" LD_LIBRARY_PATH="$(PWD)/deps/libev/.libs:$(PWD)/deps/c-ares/.libs" EMBED=0 GEVENT_CORE_CEXT_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop toxtest CPPFLAGS="-Ideps/libev -Ideps/c-ares" LDFLAGS="-Ldeps/libev/.libs -Ldeps/c-ares/.libs" LD_LIBRARY_PATH="$(PWD)/deps/libev/.libs:$(PWD)/deps/c-ares/.libs" EMBED=0 GEVENT_CORE_CEXT_ONLY=1 PYTHON=python2.7.13 PATH=$(BUILD_RUNTIMES)/versions/python2.7.13/bin:$(PATH) make develop toxtest
...@@ -97,7 +97,7 @@ for var in "$@"; do ...@@ -97,7 +97,7 @@ for var in "$@"; do
install 3.4.5 python3.4.5 install 3.4.5 python3.4.5
;; ;;
3.5) 3.5)
install 3.5.2 python3.5.2 install 3.5.3 python3.5.3
;; ;;
3.6) 3.6)
install 3.6.0 python3.6.0 install 3.6.0 python3.6.0
......
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAOoy7/QOtTjQ0niE
6uDcTwtkC0R2Tvy1AjVnXohCntZfdzbTGDoYTgXSOLsP8A697jUiJ8VCePGH50xG
Z4DKnAF3a9O3a9nr2pLXb0iY3XOMv+YEBii7CfI+3oxFYgCl0sMgHzDD2ZTVYAsm
DWgLUVsE2gHEccRwrM2tPf2EgR+FAgMBAAECgYEA3qyfyYVSeTrTYxO93x6ZaVMu
A2IZp9zSxMQL9bKiI2GRj+cV2ebSCGbg2btFnD6qBor7FWsmYz+8g6FNN/9sY4az
61rMqMtQvLBe+7L8w70FeTze4qQ4Y1oQri0qD6tBWhDVlpnbI5Py9bkZKD67yVUk
elcEA/5x4PrYXkuqsAECQQD80NjT0mDvaY0JOOaQFSEpMv6QiUA8GGX8Xli7IoKb
tAolPG8rQBa+qSpcWfDMTrWw/aWHuMEEQoP/bVDH9W4FAkEA7SYQbBAKnojZ5A3G
kOHdV7aeivRQxQk/JN8Fb8oKB9Csvpv/BsuGxPKXHdhFa6CBTTsNRtHQw/szPo4l
xMIjgQJAPoMxqibR+0EBM6+TKzteSL6oPXsCnBl4Vk/J5vPgkbmR7KUl4+7j8N8J
b2554TrxKEN/w7CGYZRE6UrRd7ATNQJAWD7Yz41sli+wfPdPU2xo1BHljyl4wMk/
EPZYbI/PCbdyAH/F935WyQTIjNeEhZc1Zkq6FwdOWw8ns3hrv3rKgQJAHXv1BqUa
czGPIFxX2TNoqtcl6/En4vrxVB1wzsfzkkDAg98kBl7qsF+S3qujSzKikjeaVbI2
/CyWR2P3yLtOmA==
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIDcjCCAtugAwIBAgIJAN5dc9TOWjB7MA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV
BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
IFNvZnR3YXJlIEZvdW5kYXRpb24xEDAOBgNVBAMMB2FsbHNhbnMwHhcNMTYwODA1
MTAyMTExWhcNMjYwODAzMTAyMTExWjBdMQswCQYDVQQGEwJYWTEXMBUGA1UEBwwO
Q2FzdGxlIEFudGhyYXgxIzAhBgNVBAoMGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0
aW9uMRAwDgYDVQQDDAdhbGxzYW5zMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
gQDqMu/0DrU40NJ4hOrg3E8LZAtEdk78tQI1Z16IQp7WX3c20xg6GE4F0ji7D/AO
ve41IifFQnjxh+dMRmeAypwBd2vTt2vZ69qS129ImN1zjL/mBAYouwnyPt6MRWIA
pdLDIB8ww9mU1WALJg1oC1FbBNoBxHHEcKzNrT39hIEfhQIDAQABo4IBODCCATQw
ggEwBgNVHREEggEnMIIBI4IHYWxsc2Fuc6AeBgMqAwSgFwwVc29tZSBvdGhlciBp
ZGVudGlmaWVyoDUGBisGAQUCAqArMCmgEBsOS0VSQkVST1MuUkVBTE2hFTAToAMC
AQGhDDAKGwh1c2VybmFtZYEQdXNlckBleGFtcGxlLm9yZ4IPd3d3LmV4YW1wbGUu
b3JnpGcwZTELMAkGA1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMw
IQYDVQQKDBpQeXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEYMBYGA1UEAwwPZGly
bmFtZSBleGFtcGxlhhdodHRwczovL3d3dy5weXRob24ub3JnL4cEfwAAAYcQAAAA
AAAAAAAAAAAAAAAAAYgEKgMEBTANBgkqhkiG9w0BAQsFAAOBgQAy16h+F+nOmeiT
VWR0fc8F/j6FcadbLseAUaogcC15OGxCl4UYpLV88HBkABOoGCpP155qwWTwOrdG
iYPGJSusf1OnJEbvzFejZf6u078bPd9/ZL4VWLjv+FPGkjd+N+/OaqMvgj8Lu99f
3Y/C4S7YbHxxwff6C6l2Xli+q6gnuQ==
-----END CERTIFICATE-----
...@@ -9,6 +9,7 @@ from test import support ...@@ -9,6 +9,7 @@ from test import support
from time import sleep from time import sleep
import unittest import unittest
import unittest.mock import unittest.mock
import tempfile
from time import monotonic as time from time import monotonic as time
try: try:
import resource import resource
...@@ -475,6 +476,16 @@ class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): ...@@ -475,6 +476,16 @@ class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn):
SELECTOR = getattr(selectors, 'EpollSelector', None) SELECTOR = getattr(selectors, 'EpollSelector', None)
def test_register_file(self):
# epoll(7) returns EPERM when given a file to watch
s = self.SELECTOR()
with tempfile.NamedTemporaryFile() as f:
with self.assertRaises(IOError):
s.register(f, selectors.EVENT_READ)
# the SelectorKey has been removed
with self.assertRaises(KeyError):
s.get_key(f)
@unittest.skipUnless(hasattr(selectors, 'KqueueSelector'), @unittest.skipUnless(hasattr(selectors, 'KqueueSelector'),
"Test needs selectors.KqueueSelector)") "Test needs selectors.KqueueSelector)")
...@@ -482,6 +493,18 @@ class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): ...@@ -482,6 +493,18 @@ class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn):
SELECTOR = getattr(selectors, 'KqueueSelector', None) SELECTOR = getattr(selectors, 'KqueueSelector', None)
def test_register_bad_fd(self):
# a file descriptor that's been closed should raise an OSError
# with EBADF
s = self.SELECTOR()
bad_f = support.make_bad_fd()
with self.assertRaises(OSError) as cm:
s.register(bad_f, selectors.EVENT_READ)
self.assertEqual(cm.exception.errno, errno.EBADF)
# the SelectorKey has been removed
with self.assertRaises(KeyError):
s.get_key(bad_f)
@unittest.skipUnless(hasattr(selectors, 'DevpollSelector'), @unittest.skipUnless(hasattr(selectors, 'DevpollSelector'),
"Test needs selectors.DevpollSelector") "Test needs selectors.DevpollSelector")
......
...@@ -199,7 +199,7 @@ class ThreadableTest: ...@@ -199,7 +199,7 @@ class ThreadableTest:
clientTearDown () clientTearDown ()
Any new test functions within the class must then define Any new test functions within the class must then define
tests in pairs, where the test name is preceeded with a tests in pairs, where the test name is preceded with a
'_' to indicate the client portion of the test. Ex: '_' to indicate the client portion of the test. Ex:
def testFoo(self): def testFoo(self):
...@@ -709,7 +709,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -709,7 +709,7 @@ class GeneralModuleTests(unittest.TestCase):
raise socket.gaierror raise socket.gaierror
def testSendtoErrors(self): def testSendtoErrors(self):
# Testing that sendto doesn't masks failures. See #10169. # Testing that sendto doesn't mask failures. See #10169.
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.addCleanup(s.close) self.addCleanup(s.close)
s.bind(('', 0)) s.bind(('', 0))
...@@ -1304,7 +1304,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1304,7 +1304,7 @@ class GeneralModuleTests(unittest.TestCase):
# socket.gethostbyaddr('испытание.python.org') # socket.gethostbyaddr('испытание.python.org')
def check_sendall_interrupted(self, with_timeout): def check_sendall_interrupted(self, with_timeout):
# socketpair() is not stricly required, but it makes things easier. # socketpair() is not strictly required, but it makes things easier.
if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'): if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'):
self.skipTest("signal.alarm and socket.socketpair required for this test") self.skipTest("signal.alarm and socket.socketpair required for this test")
# Our signal handlers clobber the C errno by calling a math function # Our signal handlers clobber the C errno by calling a math function
...@@ -1374,6 +1374,20 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1374,6 +1374,20 @@ class GeneralModuleTests(unittest.TestCase):
self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.writable)
self.assertRaises(ValueError, fp.seekable) self.assertRaises(ValueError, fp.seekable)
def test_makefile_mode(self):
for mode in 'r', 'rb', 'rw', 'w', 'wb':
with self.subTest(mode=mode):
with socket.socket() as sock:
with sock.makefile(mode) as fp:
self.assertEqual(fp.mode, mode)
def test_makefile_invalid_mode(self):
for mode in 'rt', 'x', '+', 'a':
with self.subTest(mode=mode):
with socket.socket() as sock:
with self.assertRaisesRegex(ValueError, 'invalid mode'):
sock.makefile(mode)
def test_pickle(self): def test_pickle(self):
sock = socket.socket() sock = socket.socket()
with sock: with sock:
...@@ -1428,11 +1442,31 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1428,11 +1442,31 @@ class GeneralModuleTests(unittest.TestCase):
# type and populates the socket object. # type and populates the socket object.
# #
# On Windows this trick won't work, so the test is skipped. # On Windows this trick won't work, so the test is skipped.
fd, _ = tempfile.mkstemp() fd, path = tempfile.mkstemp()
self.addCleanup(os.unlink, path)
with socket.socket(family=42424, type=13331, fileno=fd) as s: with socket.socket(family=42424, type=13331, fileno=fd) as s:
self.assertEqual(s.family, 42424) self.assertEqual(s.family, 42424)
self.assertEqual(s.type, 13331) self.assertEqual(s.type, 13331)
@unittest.skipUnless(hasattr(os, 'sendfile'), 'test needs os.sendfile()')
def test__sendfile_use_sendfile(self):
class File:
def __init__(self, fd):
self.fd = fd
def fileno(self):
return self.fd
with socket.socket() as sock:
fd = os.open(os.curdir, os.O_RDONLY)
os.close(fd)
with self.assertRaises(socket._GiveupOnSendfile):
sock._sendfile_use_sendfile(File(fd))
with self.assertRaises(OverflowError):
sock._sendfile_use_sendfile(File(2**1000))
with self.assertRaises(TypeError):
sock._sendfile_use_sendfile(File(None))
@unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.')
class BasicCANTest(unittest.TestCase): class BasicCANTest(unittest.TestCase):
...@@ -4596,9 +4630,10 @@ class BufferIOTest(SocketConnectedTest): ...@@ -4596,9 +4630,10 @@ class BufferIOTest(SocketConnectedTest):
SocketConnectedTest.__init__(self, methodName=methodName) SocketConnectedTest.__init__(self, methodName=methodName)
def testRecvIntoArray(self): def testRecvIntoArray(self):
buf = bytearray(1024) buf = array.array("B", [0] * len(MSG))
nbytes = self.cli_conn.recv_into(buf) nbytes = self.cli_conn.recv_into(buf)
self.assertEqual(nbytes, len(MSG)) self.assertEqual(nbytes, len(MSG))
buf = buf.tobytes()
msg = buf[:len(MSG)] msg = buf[:len(MSG)]
self.assertEqual(msg, MSG) self.assertEqual(msg, MSG)
...@@ -4625,9 +4660,10 @@ class BufferIOTest(SocketConnectedTest): ...@@ -4625,9 +4660,10 @@ class BufferIOTest(SocketConnectedTest):
_testRecvIntoMemoryview = _testRecvIntoArray _testRecvIntoMemoryview = _testRecvIntoArray
def testRecvFromIntoArray(self): def testRecvFromIntoArray(self):
buf = bytearray(1024) buf = array.array("B", [0] * len(MSG))
nbytes, addr = self.cli_conn.recvfrom_into(buf) nbytes, addr = self.cli_conn.recvfrom_into(buf)
self.assertEqual(nbytes, len(MSG)) self.assertEqual(nbytes, len(MSG))
buf = buf.tobytes()
msg = buf[:len(MSG)] msg = buf[:len(MSG)]
self.assertEqual(msg, MSG) self.assertEqual(msg, MSG)
...@@ -4681,9 +4717,17 @@ def isTipcAvailable(): ...@@ -4681,9 +4717,17 @@ def isTipcAvailable():
""" """
if not hasattr(socket, "AF_TIPC"): if not hasattr(socket, "AF_TIPC"):
return False return False
if not os.path.isfile("/proc/modules"): try:
return False f = open("/proc/modules")
with open("/proc/modules") as f: except IOError as e:
# It's ok if the file does not exist, is a directory or if we
# have not the permission to read it. In any other case it's a
# real error, so raise it again.
if e.errno in (errno.ENOENT, errno.EISDIR, errno.EACCES):
return False
else:
raise
with f:
for line in f: for line in f:
if line.startswith("tipc "): if line.startswith("tipc "):
return True return True
...@@ -4733,7 +4777,7 @@ class TIPCThreadableTest(unittest.TestCase, ThreadableTest): ...@@ -4733,7 +4777,7 @@ class TIPCThreadableTest(unittest.TestCase, ThreadableTest):
self.addCleanup(self.conn.close) self.addCleanup(self.conn.close)
def clientSetUp(self): def clientSetUp(self):
# The is a hittable race between serverExplicitReady() and the # There is a hittable race between serverExplicitReady() and the
# accept() call; sleep a little while to avoid it, otherwise # accept() call; sleep a little while to avoid it, otherwise
# we could get an exception # we could get an exception
time.sleep(0.1) time.sleep(0.1)
...@@ -4974,7 +5018,7 @@ class TestSocketSharing(SocketTCPTest): ...@@ -4974,7 +5018,7 @@ class TestSocketSharing(SocketTCPTest):
def compareSockets(self, org, other): def compareSockets(self, org, other):
# socket sharing is expected to work only for blocking socket # socket sharing is expected to work only for blocking socket
# since the internal python timout value isn't transfered. # since the internal python timeout value isn't transferred.
self.assertEqual(org.gettimeout(), None) self.assertEqual(org.gettimeout(), None)
self.assertEqual(org.gettimeout(), other.gettimeout()) self.assertEqual(org.gettimeout(), other.gettimeout())
......
This diff is collapsed.
This diff is collapsed.
...@@ -3,7 +3,8 @@ Tests for the threading module. ...@@ -3,7 +3,8 @@ Tests for the threading module.
""" """
import test.support import test.support
from test.support import verbose, strip_python_stderr, import_module, cpython_only from test.support import (verbose, import_module, cpython_only,
requires_type_collecting)
from test.support.script_helper import assert_python_ok, assert_python_failure from test.support.script_helper import assert_python_ok, assert_python_failure
import random import random
...@@ -58,7 +59,7 @@ class TestThread(threading.Thread): ...@@ -58,7 +59,7 @@ class TestThread(threading.Thread):
self.nrunning.inc() self.nrunning.inc()
if verbose: if verbose:
print(self.nrunning.get(), 'tasks are running') print(self.nrunning.get(), 'tasks are running')
self.testcase.assertTrue(self.nrunning.get() <= 3) self.testcase.assertLessEqual(self.nrunning.get(), 3)
time.sleep(delay) time.sleep(delay)
if verbose: if verbose:
...@@ -66,7 +67,7 @@ class TestThread(threading.Thread): ...@@ -66,7 +67,7 @@ class TestThread(threading.Thread):
with self.mutex: with self.mutex:
self.nrunning.dec() self.nrunning.dec()
self.testcase.assertTrue(self.nrunning.get() >= 0) self.testcase.assertGreaterEqual(self.nrunning.get(), 0)
if verbose: if verbose:
print('%s is finished. %d tasks are running' % print('%s is finished. %d tasks are running' %
(self.name, self.nrunning.get())) (self.name, self.nrunning.get()))
...@@ -100,26 +101,25 @@ class ThreadTests(BaseTestCase): ...@@ -100,26 +101,25 @@ class ThreadTests(BaseTestCase):
for i in range(NUMTASKS): for i in range(NUMTASKS):
t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning) t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
threads.append(t) threads.append(t)
self.assertEqual(t.ident, None) self.assertIsNone(t.ident)
self.assertTrue(re.match('<TestThread\(.*, initial\)>', repr(t))) self.assertRegex(repr(t), r'^<TestThread\(.*, initial\)>$')
t.start() t.start()
if verbose: if verbose:
print('waiting for all tasks to complete') print('waiting for all tasks to complete')
for t in threads: for t in threads:
t.join() t.join()
self.assertTrue(not t.is_alive()) self.assertFalse(t.is_alive())
self.assertNotEqual(t.ident, 0) self.assertNotEqual(t.ident, 0)
self.assertFalse(t.ident is None) self.assertIsNotNone(t.ident)
self.assertTrue(re.match('<TestThread\(.*, stopped -?\d+\)>', self.assertRegex(repr(t), r'^<TestThread\(.*, stopped -?\d+\)>$')
repr(t)))
if verbose: if verbose:
print('all tasks done') print('all tasks done')
self.assertEqual(numrunning.get(), 0) self.assertEqual(numrunning.get(), 0)
def test_ident_of_no_threading_threads(self): def test_ident_of_no_threading_threads(self):
# The ident still must work for the main thread and dummy threads. # The ident still must work for the main thread and dummy threads.
self.assertFalse(threading.currentThread().ident is None) self.assertIsNotNone(threading.currentThread().ident)
def f(): def f():
ident.append(threading.currentThread().ident) ident.append(threading.currentThread().ident)
done.set() done.set()
...@@ -127,7 +127,7 @@ class ThreadTests(BaseTestCase): ...@@ -127,7 +127,7 @@ class ThreadTests(BaseTestCase):
ident = [] ident = []
_thread.start_new_thread(f, ()) _thread.start_new_thread(f, ())
done.wait() done.wait()
self.assertFalse(ident[0] is None) self.assertIsNotNone(ident[0])
# Kill the "immortal" _DummyThread # Kill the "immortal" _DummyThread
del threading._active[ident[0]] del threading._active[ident[0]]
...@@ -244,7 +244,7 @@ class ThreadTests(BaseTestCase): ...@@ -244,7 +244,7 @@ class ThreadTests(BaseTestCase):
self.assertTrue(ret) self.assertTrue(ret)
if verbose: if verbose:
print(" verifying worker hasn't exited") print(" verifying worker hasn't exited")
self.assertTrue(not t.finished) self.assertFalse(t.finished)
if verbose: if verbose:
print(" attempting to raise asynch exception in worker") print(" attempting to raise asynch exception in worker")
result = set_async_exc(ctypes.c_long(t.id), exception) result = set_async_exc(ctypes.c_long(t.id), exception)
...@@ -415,9 +415,9 @@ class ThreadTests(BaseTestCase): ...@@ -415,9 +415,9 @@ class ThreadTests(BaseTestCase):
def test_repr_daemon(self): def test_repr_daemon(self):
t = threading.Thread() t = threading.Thread()
self.assertFalse('daemon' in repr(t)) self.assertNotIn('daemon', repr(t))
t.daemon = True t.daemon = True
self.assertTrue('daemon' in repr(t)) self.assertIn('daemon', repr(t))
def test_deamon_param(self): def test_deamon_param(self):
t = threading.Thread() t = threading.Thread()
...@@ -569,7 +569,7 @@ class ThreadTests(BaseTestCase): ...@@ -569,7 +569,7 @@ class ThreadTests(BaseTestCase):
tstate_lock.release() tstate_lock.release()
self.assertFalse(t.is_alive()) self.assertFalse(t.is_alive())
# And verify the thread disposed of _tstate_lock. # And verify the thread disposed of _tstate_lock.
self.assertTrue(t._tstate_lock is None) self.assertIsNone(t._tstate_lock)
def test_repr_stopped(self): def test_repr_stopped(self):
# Verify that "stopped" shows up in repr(Thread) appropriately. # Verify that "stopped" shows up in repr(Thread) appropriately.
...@@ -988,6 +988,7 @@ class ThreadingExceptionTests(BaseTestCase): ...@@ -988,6 +988,7 @@ class ThreadingExceptionTests(BaseTestCase):
self.assertIn("ZeroDivisionError", err) self.assertIn("ZeroDivisionError", err)
self.assertNotIn("Unhandled exception", err) self.assertNotIn("Unhandled exception", err)
@requires_type_collecting
def test_print_exception_stderr_is_none_1(self): def test_print_exception_stderr_is_none_1(self):
script = r"""if True: script = r"""if True:
import sys import sys
...@@ -1042,6 +1043,24 @@ class ThreadingExceptionTests(BaseTestCase): ...@@ -1042,6 +1043,24 @@ class ThreadingExceptionTests(BaseTestCase):
self.assertEqual(out, b'') self.assertEqual(out, b'')
self.assertNotIn("Unhandled exception", err.decode()) self.assertNotIn("Unhandled exception", err.decode())
def test_bare_raise_in_brand_new_thread(self):
def bare_raise():
raise
class Issue27558(threading.Thread):
exc = None
def run(self):
try:
bare_raise()
except Exception as exc:
self.exc = exc
thread = Issue27558()
thread.start()
thread.join()
self.assertIsNotNone(thread.exc)
self.assertIsInstance(thread.exc, RuntimeError)
class TimerTests(BaseTestCase): class TimerTests(BaseTestCase):
...@@ -1095,7 +1114,7 @@ class EventTests(lock_tests.EventTests): ...@@ -1095,7 +1114,7 @@ class EventTests(lock_tests.EventTests):
pass pass
class ConditionAsRLockTests(lock_tests.RLockTests): class ConditionAsRLockTests(lock_tests.RLockTests):
# An Condition uses an RLock by default and exports its API. # Condition uses an RLock by default and exports its API.
locktype = staticmethod(threading.Condition) locktype = staticmethod(threading.Condition)
class ConditionTests(lock_tests.ConditionTests): class ConditionTests(lock_tests.ConditionTests):
......
=================
Versioned Tests
=================
The test directories that begin with a number (e.g., 2.7 and 3.5) are
copies of the standard library tests for that specific version of
Python. Each directory has a ``version`` file that identifies the
specific point release the tests come from. The tests are only
expected to pass if the version of python running the tests exactly
matches the version in that file. If this is not the case, the test
runner will print a warning.
.. caution:: For ease of updating the standard library tests, gevent
tries very hard not to modify the tests if at all
possible. Prefer to use the ``patched_tests_setup.py`` or
``known_failures.py`` file if necessary.
...@@ -520,6 +520,8 @@ if sys.version_info[:2] >= (3, 5): ...@@ -520,6 +520,8 @@ if sys.version_info[:2] >= (3, 5):
# XXX: Hangs # XXX: Hangs
'test_ssl.ThreadedTests.test_nonblocking_send', 'test_ssl.ThreadedTests.test_nonblocking_send',
'test_ssl.ThreadedTests.test_socketserver', 'test_ssl.ThreadedTests.test_socketserver',
# Uses direct sendfile, doesn't properly check for it being enabled
'test_socket.GeneralModuleTests.test__sendfile_use_sendfile',
# Relies on the regex of the repr having the locked state (TODO: it'd be nice if # Relies on the regex of the repr having the locked state (TODO: it'd be nice if
# we did that). # we did that).
# XXX: These are commented out in the source code of test_threading because # XXX: These are commented out in the source code of test_threading because
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment