-
Notifications
You must be signed in to change notification settings - Fork 18
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 #3 from claws/upstream
Add zstr test
- Loading branch information
Showing
2 changed files
with
36 additions
and
6 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
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,29 @@ | ||
""" | ||
Replicates czmq test_zstr | ||
""" | ||
|
||
from pyczmq import zmq, zctx, zsocket, zstr | ||
|
||
def test_zstr(): | ||
ctx = zctx.new() | ||
test_endpoint = 'inproc://zstr.test' | ||
output_s = zsocket.new(ctx, zmq.PAIR) | ||
zsocket.bind(output_s, test_endpoint) | ||
input_s = zsocket.new(ctx, zmq.PAIR) | ||
zsocket.connect(input_s, test_endpoint) | ||
|
||
# Send ten strings, five strings with MORE flag and then END | ||
for i in range(0, 10): | ||
rc = zstr.send(output_s, "this is string {}".format(i)) | ||
assert(rc == 0) | ||
zstr.sendx(output_s, "This", "is", "almost", "the", "very", "END") | ||
|
||
# Read and count until we receive END | ||
string_nbr = 0 | ||
while True: | ||
string = zstr.recv(input_s) | ||
if string == "END": | ||
break | ||
string_nbr += 1 | ||
assert(string_nbr == 15) | ||
|