This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from maralla/socket_shutdown
fix socket shutdown bug
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
|
||
from thriftpy.transport.socket import TSocket, TServerSocket | ||
from thriftpy.transport import TTransportException | ||
|
||
|
||
def test_close(): | ||
server = TServerSocket(host="localhost", port=12345) | ||
client = TSocket(host="localhost", port=12345) | ||
|
||
server.listen() | ||
client.open() | ||
|
||
c = server.accept() | ||
|
||
client.close() | ||
|
||
with pytest.raises(TTransportException) as e: | ||
c.read(1024) | ||
assert "TSocket read 0 bytes" in e.value.message | ||
|
||
c.write(b"world") | ||
c.close() | ||
|
||
assert c.handle is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters