Commit c6664e72 authored by Denis Bilenko's avatar Denis Bilenko

test__socket_close.py: create socket inside the test case (to pass totalrefcount check)

parent e94dcf35
......@@ -7,26 +7,23 @@ import greentest
class Test(greentest.TestCase):
def setUp(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect(('www.google.com', 80))
def tearDown(self):
self.sock.close()
def test_recv_closed(self):
receiver = gevent.spawn(self.sock.recv, 25)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('www.google.com', 80))
receiver = gevent.spawn(sock.recv, 25)
gevent.sleep(0.001)
self.sock.close()
sock.close()
receiver.join(timeout=0.001)
assert receiver.ready(), receiver
self.assertEqual(receiver.value, '')
def test_recv_twice(self):
receiver = gevent.spawn(self.sock.recv, 25)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('www.google.com', 80))
receiver = gevent.spawn(sock.recv, 25)
gevent.sleep(0.001)
self.assertRaises(AssertionError, self.sock.recv, 25)
self.assertRaises(AssertionError, self.sock.recv, 25)
self.assertRaises(AssertionError, sock.recv, 25)
self.assertRaises(AssertionError, sock.recv, 25)
receiver.kill()
......
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