aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPedro Worcel <pedro@worcel.com>2014-02-22 16:32:22 +1300
committerPedro Worcel <pedro@worcel.com>2014-02-22 16:32:22 +1300
commit4284fd3614561fe5e2c53154defb3774f14c589c (patch)
treed26bbe6d369a00cdf96778c10fa53be2a73ff9cc /test
parent3c02865e8b5839d536bc9982e4c0e6e699fd1943 (diff)
downloadmitmproxy-4284fd3614561fe5e2c53154defb3774f14c589c.tar.gz
mitmproxy-4284fd3614561fe5e2c53154defb3774f14c589c.tar.bz2
mitmproxy-4284fd3614561fe5e2c53154defb3774f14c589c.zip
add multi-line support to backwards search
Diffstat (limited to 'test')
-rw-r--r--test/test_console_search.py38
1 files changed, 30 insertions, 8 deletions
diff --git a/test/test_console_search.py b/test/test_console_search.py
index 69c033b9..60b998cc 100644
--- a/test/test_console_search.py
+++ b/test/test_console_search.py
@@ -38,8 +38,8 @@ def test_search_highlights_clears_prev():
text_object = tutils.get_body_line(f.last_displayed_body, 0)
assert text_object.get_text() != ('this is string', [(None, 8), (f.highlight_color, 6)])
-def test_search_highlights_multi_line():
- f = tutils.tflowview(request_contents="this is string\nstring is string")
+def test_search_highlights_multi_line(flow=None):
+ f = flow if flow else tutils.tflowview(request_contents="this is string\nstring is string")
# should highlight the first line.
f.search("string")
@@ -54,7 +54,6 @@ def test_search_highlights_multi_line():
# should highlight third line, second appearance of string.
f.search("string")
text_object = tutils.get_body_line(f.last_displayed_body, 1)
- print(text_object.get_text(), ('string is string', [(None, 10), (f.highlight_color, 6)]))
assert text_object.get_text() == ('string is string', [(None, 10), (f.highlight_color, 6)])
def test_search_loops():
@@ -122,15 +121,38 @@ def test_search_backwards():
def test_search_back_multiline():
f = tutils.tflowview(request_contents="this is string\nstring is string")
- f.search("string")
+ # shared assertions. highlight and pointers should now be on the third
+ # 'string' appearance
+ test_search_highlights_multi_line(f)
+
+ # should highlight second line, first appearance of string.
+ f.search_again(backwards=True)
+ text_object = tutils.get_body_line(f.last_displayed_body, 1)
+ assert text_object.get_text() == ('string is string', [(None, 0), (f.highlight_color, 6)])
+
+ # should highlight the first line again.
+ f.search_again(backwards=True)
text_object = tutils.get_body_line(f.last_displayed_body, 0)
- first_match = ('this is string', [(None, 8), (f.highlight_color, 6)])
- assert text_object.get_text() == first_match
+ assert text_object.get_text() == ('this is string', [(None, 8), (f.highlight_color, 6)])
+def test_search_back_multi_multi_line():
+ """
+ same as above for some bugs the above won't catch.
+ """
+ f = tutils.tflowview(request_contents="this is string\nthis is string\nthis is string")
+
+ f.search("string")
f.search_again()
+ f.search_again()
+
+ # should be on second line
+ f.search_again(backwards=True)
text_object = tutils.get_body_line(f.last_displayed_body, 1)
- assert text_object.get_text() == ('string is string', [(None, 0), (f.highlight_color, 6)])
+ assert text_object.get_text() == ('this is string', [(None, 8), (f.highlight_color, 6)])
+ # first line now
f.search_again(backwards=True)
text_object = tutils.get_body_line(f.last_displayed_body, 0)
- assert text_object.get_text() == first_match
+ print(text_object.get_text(), ('this is string', [(None, 8), (f.highlight_color, 6)]))
+ assert text_object.get_text() == ('this is string', [(None, 8), (f.highlight_color, 6)])
+