From 460107589c2ef425ef124c74908be1fa86ebab9d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 27 Jan 2011 10:29:37 +1300 Subject: Add tab completion for save and load path specs. --- test/test_console.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_console.py b/test/test_console.py index c5c856f8..cfafed96 100644 --- a/test/test_console.py +++ b/test/test_console.py @@ -288,9 +288,39 @@ class uformat_keyvals(libpry.AutoTree): ] ) +class uPathCompleter(libpry.AutoTree): + 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 + + tests = [ uFlow(), uformat_keyvals(), - uState() + uState(), + uPathCompleter() ] -- cgit v1.2.3