summaryrefslogtreecommitdiff
path: root/tests/test_performance.py
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2018-01-15 16:43:10 -0500
committerRyan Petrello <lists@ryanpetrello.com>2018-02-05 16:07:38 -0500
commitfd7332f59e003a8ee658647f883d4b03018c5e5b (patch)
tree86f195b5ad8d0ff1ec5663c19c3b9de81c9334e5 /tests/test_performance.py
parent28e82cda5056df20ec55995ea7fe66abd346f6bb (diff)
downloadpexpect-git-fd7332f59e003a8ee658647f883d4b03018c5e5b.tar.gz
optimize pty buffering and searching
Python strings are slow and expensive as buffers because they're immutable; replace the output buffer with a StringIO/BytesIO object see: https://github.com/pexpect/pexpect/issues/438
Diffstat (limited to 'tests/test_performance.py')
-rwxr-xr-xtests/test_performance.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_performance.py b/tests/test_performance.py
index 7be0cf6..63778af 100755
--- a/tests/test_performance.py
+++ b/tests/test_performance.py
@@ -23,6 +23,7 @@ from __future__ import print_function
import unittest, time, sys
import platform
import pexpect
+import re
from . import PexpectTestCase
# This isn't exactly a unit test, but it fits in nicely with the rest of the tests.
@@ -101,6 +102,11 @@ class PerformanceTestCase (PexpectTestCase.PexpectTestCase):
self.faster_range(100000)
print("100000 calls to faster_range:", (time.time() - start_time))
+ def test_large_stdout_stream(self):
+ e = pexpect.spawn('openssl rand -base64 {}'.format(1024*1024*25), searchwindowsize=1000)
+ resp = e.expect(['Password:', pexpect.EOF, pexpect.TIMEOUT])
+ assert resp == 1 # index 1 == EOF
+
if __name__ == "__main__":
unittest.main()