Skip to content

Commit c472360

Browse files
author
Pan
committed
Added file read from generator with timeout set should not timeout test.
1 parent db0de23 commit c472360

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_pssh_ssh2_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,25 @@ def test_timeout_file_read(self):
12291229
finally:
12301230
os.unlink(_file)
12311231

1232+
def test_file_read_no_timeout(self):
1233+
try:
1234+
xrange
1235+
except NameError:
1236+
xrange = range
1237+
dir_name = os.path.dirname(__file__)
1238+
_file = os.sep.join((dir_name, 'file_to_read'))
1239+
contents = [b'a line\n' for _ in xrange(10000)]
1240+
with open(_file, 'wb') as fh:
1241+
fh.writelines(contents)
1242+
output = self.client.run_command('cat %s' % (_file,), timeout=10)
1243+
try:
1244+
_out = list(output[self.client.hosts[0]].stdout)
1245+
finally:
1246+
os.unlink(_file)
1247+
_contents = [c.decode('utf-8').strip() for c in contents]
1248+
self.assertEqual(len(contents), len(_out))
1249+
self.assertListEqual(_contents, _out)
1250+
12321251
## OpenSSHServer needs to run in its own thread for this test to work
12331252
## Race conditions otherwise.
12341253
#

0 commit comments

Comments
 (0)