summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2023-01-27 17:59:55 -0500
committerJeff Forcier <jeff@bitprophet.org>2023-01-27 17:59:55 -0500
commitd766ba92f4775b8a70f8ea3606dceb28eefa8810 (patch)
tree67fa735d897706dd9df278908ac5b7a4d5eda621
parent03ab8c3cbffa0d28964fd208abf0f13c04149d29 (diff)
downloadparamiko-d766ba92f4775b8a70f8ea3606dceb28eefa8810.tar.gz
Twiddle ProxyCommand read test to not have faux misspellings, and to be way more understandable
-rw-r--r--tests/test_proxy.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
index 3d767729..22c2c9c3 100644
--- a/tests/test_proxy.py
+++ b/tests/test_proxy.py
@@ -43,14 +43,20 @@ class TestProxyCommand:
stdout = Popen.return_value.stdout
select.return_value = [stdout], None, None
fileno = stdout.fileno.return_value
- # Intentionally returning <5 at a time sometimes
- os_read.side_effect = [b"was", b"te", b"of ti", b"me"]
+ # Force os.read to return smaller-than-requested chunks
+ os_read.side_effect = [b"was", b"t", b"e", b"of ti", b"me"]
proxy = ProxyCommand("hi")
+ # Ask for 5 bytes (ie b"waste")
data = proxy.recv(5)
+ # Ensure we got "waste" stitched together
assert data == b"waste"
+ # Ensure the calls happened in the sizes expected (starting with the
+ # initial "I want all 5 bytes", followed by "I want whatever I believe
+ # should be left after what I've already read", until done)
assert [x[0] for x in os_read.call_args_list] == [
- (fileno, 5),
- (fileno, 2),
+ (fileno, 5), # initial
+ (fileno, 2), # I got 3, want 2 more
+ (fileno, 1), # I've now got 4, want 1 more
]
@patch("paramiko.proxy.subprocess.Popen")