You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/gevent/tests/test__socket_ex.py

44 lines
1.1 KiB

import gevent.testing as greentest
from gevent import socket
import errno
import sys
class TestClosedSocket(greentest.TestCase):
switch_expected = False
def test(self):
sock = socket.socket()
sock.close()
try:
sock.send(b'a', timeout=1)
raise AssertionError("Should not get here")
except (socket.error, OSError) as ex:
if ex.args[0] != errno.EBADF:
if sys.platform.startswith('win'):
# Windows/Py3 raises "OSError: [WinError 10038] "
# which is not standard and not what it does
# on Py2.
pass
else:
raise
class TestRef(greentest.TestCase):
switch_expected = False
def test(self):
sock = socket.socket()
assert sock.ref is True, sock.ref
sock.ref = False
assert sock.ref is False, sock.ref
assert sock._read_event.ref is False, sock.ref
assert sock._write_event.ref is False, sock.ref
sock.close()
if __name__ == '__main__':
greentest.main()