diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-03-20 10:54:57 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-03-20 10:54:57 +1300 |
commit | 560e44c637e4f1fcbeba1305fc1eb39e3d796013 (patch) | |
tree | c7ca1308ce79ed9195ffffa7cfb9b5abdce50008 /test | |
parent | a3f4296bf1ba0ac1a72d5a44a504d375707fdc39 (diff) | |
download | mitmproxy-560e44c637e4f1fcbeba1305fc1eb39e3d796013.tar.gz mitmproxy-560e44c637e4f1fcbeba1305fc1eb39e3d796013.tar.bz2 mitmproxy-560e44c637e4f1fcbeba1305fc1eb39e3d796013.zip |
Pull PathEdit out into its own file.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_console.py | 43 | ||||
-rw-r--r-- | test/test_console_pathedit.py | 48 |
2 files changed, 48 insertions, 43 deletions
diff --git a/test/test_console.py b/test/test_console.py index d66bd8b0..419b94a7 100644 --- a/test/test_console.py +++ b/test/test_console.py @@ -104,48 +104,5 @@ def test_format_keyvals(): ) -class TestPathCompleter: - def test_lookup_construction(self): - c = console._PathCompleter() - - cd = tutils.test_data.path("completion") - ca = os.path.join(cd, "a") - assert c.complete(ca).endswith(normpath("/completion/aaa")) - assert c.complete(ca).endswith(normpath("/completion/aab")) - c.reset() - ca = os.path.join(cd, "aaa") - assert c.complete(ca).endswith(normpath("/completion/aaa")) - assert c.complete(ca).endswith(normpath("/completion/aaa")) - c.reset() - assert c.complete(cd).endswith(normpath("/completion/aaa")) - - def test_completion(self): - c = console._PathCompleter(True) - c.reset() - c.lookup = [ - ("a", "x/a"), - ("aa", "x/aa"), - ] - assert c.complete("a") == "a" - assert c.final == "x/a" - assert c.complete("a") == "aa" - assert c.complete("a") == "a" - - c = console._PathCompleter(True) - r = c.complete("l") - assert c.final.endswith(r) - - c.reset() - assert c.complete("/nonexistent") == "/nonexistent" - assert c.final == "/nonexistent" - c.reset() - assert c.complete("~") != "~" - - c.reset() - s = "thisisatotallynonexistantpathforsure" - assert c.complete(s) == s - assert c.final == s - - def test_options(): assert console.Options(kill=True) diff --git a/test/test_console_pathedit.py b/test/test_console_pathedit.py new file mode 100644 index 00000000..605e1e2f --- /dev/null +++ b/test/test_console_pathedit.py @@ -0,0 +1,48 @@ +import os +from os.path import normpath +from libmproxy.console import pathedit + +import tutils + + +class TestPathCompleter: + def test_lookup_construction(self): + c = pathedit._PathCompleter() + + cd = tutils.test_data.path("completion") + ca = os.path.join(cd, "a") + assert c.complete(ca).endswith(normpath("/completion/aaa")) + assert c.complete(ca).endswith(normpath("/completion/aab")) + c.reset() + ca = os.path.join(cd, "aaa") + assert c.complete(ca).endswith(normpath("/completion/aaa")) + assert c.complete(ca).endswith(normpath("/completion/aaa")) + c.reset() + assert c.complete(cd).endswith(normpath("/completion/aaa")) + + def test_completion(self): + c = pathedit._PathCompleter(True) + c.reset() + c.lookup = [ + ("a", "x/a"), + ("aa", "x/aa"), + ] + assert c.complete("a") == "a" + assert c.final == "x/a" + assert c.complete("a") == "aa" + assert c.complete("a") == "a" + + c = pathedit._PathCompleter(True) + r = c.complete("l") + assert c.final.endswith(r) + + c.reset() + assert c.complete("/nonexistent") == "/nonexistent" + assert c.final == "/nonexistent" + c.reset() + assert c.complete("~") != "~" + + c.reset() + s = "thisisatotallynonexistantpathforsure" + assert c.complete(s) == s + assert c.final == s |