33import sys
44from itertools import islice
55from mock import Mock
6- from bpython import config , repl , cli
6+ from bpython import config , repl , cli , autocomplete
77
88def setup_config (conf ):
99 config_struct = config .Struct ()
@@ -249,7 +249,7 @@ def test_push(self):
249249 # COMPLETE TESTS
250250 # 1. Global tests
251251 def test_simple_global_complete (self ):
252- self .repl = FakeRepl ({'autocomplete_mode' :1 })
252+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SIMPLE })
253253 self .repl .input_line = "d"
254254 self .repl .current_word = "d"
255255
@@ -259,7 +259,7 @@ def test_simple_global_complete(self):
259259 ['def' , 'del' , 'delattr(' , 'dict(' , 'dir(' , 'divmod(' ])
260260
261261 def test_substring_global_complete (self ):
262- self .repl = FakeRepl ({'autocomplete_mode' :2 })
262+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SUBSTRING })
263263 self .repl .input_line = "time"
264264 self .repl .current_word = "time"
265265
@@ -269,7 +269,7 @@ def test_substring_global_complete(self):
269269 ['RuntimeError(' , 'RuntimeWarning(' ])
270270
271271 def test_fuzzy_global_complete (self ):
272- self .repl = FakeRepl ({'autocomplete_mode' :3 })
272+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . FUZZY })
273273 self .repl .input_line = "doc"
274274 self .repl .current_word = "doc"
275275
@@ -280,7 +280,7 @@ def test_fuzzy_global_complete(self):
280280
281281 # 2. Attribute tests
282282 def test_simple_attribute_complete (self ):
283- self .repl = FakeRepl ({'autocomplete_mode' :1 })
283+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SIMPLE })
284284 self .repl .input_line = "Foo.b"
285285 self .repl .current_word = "Foo.b"
286286
@@ -294,7 +294,7 @@ def test_simple_attribute_complete(self):
294294 ['Foo.bar' ])
295295
296296 def test_substring_attribute_complete (self ):
297- self .repl = FakeRepl ({'autocomplete_mode' :2 })
297+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SUBSTRING })
298298 self .repl .input_line = "Foo.ar"
299299 self .repl .current_word = "Foo.ar"
300300
@@ -308,7 +308,7 @@ def test_substring_attribute_complete(self):
308308 ['Foo.bar' ])
309309
310310 def test_fuzzy_attribute_complete (self ):
311- self .repl = FakeRepl ({'autocomplete_mode' :3 })
311+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . FUZZY })
312312 self .repl .input_line = "Foo.br"
313313 self .repl .current_word = "Foo.br"
314314
@@ -323,7 +323,7 @@ def test_fuzzy_attribute_complete(self):
323323
324324 # 3. Edge Cases
325325 def test_updating_namespace_complete (self ):
326- self .repl = FakeRepl ({'autocomplete_mode' :1 })
326+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SIMPLE })
327327 self .repl .input_line = "foo"
328328 self .repl .current_word = "foo"
329329 self .repl .push ("foobar = 2" )
@@ -334,7 +334,7 @@ def test_updating_namespace_complete(self):
334334 ['foobar' ])
335335
336336 def test_file_should_not_appear_in_complete (self ):
337- self .repl = FakeRepl ({'autocomplete_mode' :1 })
337+ self .repl = FakeRepl ({'autocomplete_mode' : autocomplete . SIMPLE })
338338 self .repl .input_line = "_"
339339 self .repl .current_word = "_"
340340 self .assertTrue (self .repl .complete ())
@@ -423,7 +423,7 @@ def setup_matches(tab=False):
423423 self .repl .config .tab_length = 4
424424 self .repl .config .auto_display_list = True
425425 self .repl .config .list_win_visible = True
426- self .repl .config .autocomplete_mode = 1
426+ self .repl .config .autocomplete_mode = autocomplete . SIMPLE
427427
428428 # 3 Types of tab complete
429429 def test_simple_tab_complete (self ):
@@ -433,15 +433,15 @@ def test_simple_tab_complete(self):
433433
434434 def test_substring_tab_complete (self ):
435435 self .repl .s = "bar"
436- self .repl .config .autocomplete_mode = 3
436+ self .repl .config .autocomplete_mode = autocomplete . FUZZY
437437 self .repl .tab ()
438438 self .assertEqual (self .repl .s , "foobar" )
439439 self .repl .tab ()
440440 self .assertEqual (self .repl .s , "foofoobar" )
441441
442442 def test_fuzzy_tab_complete (self ):
443443 self .repl .s = "br"
444- self .repl .config .autocomplete_mode = 3
444+ self .repl .config .autocomplete_mode = autocomplete . FUZZY
445445 self .repl .tab ()
446446 self .assertEqual (self .repl .s , "foobar" )
447447
@@ -482,15 +482,15 @@ def test_current_word(self):
482482 def test_fuzzy_attribute_tab_complete (self ):
483483 """Test fuzzy attribute with no text"""
484484 self .repl .s = "Foo."
485- self .repl .config .autocomplete_mode = 3
485+ self .repl .config .autocomplete_mode = autocomplete . FUZZY
486486
487487 self .repl .tab ()
488488 self .assertEqual (self .repl .s , "Foo.foobar" )
489489
490490 def test_fuzzy_attribute_tab_complete2 (self ):
491491 """Test fuzzy attribute with some text"""
492492 self .repl .s = "Foo.br"
493- self .repl .config .autocomplete_mode = 3
493+ self .repl .config .autocomplete_mode = autocomplete . FUZZY
494494
495495 self .repl .tab ()
496496 self .assertEqual (self .repl .s , "Foo.foobar" )
@@ -502,7 +502,7 @@ def test_simple_expand(self):
502502 self .assertEqual (self .repl .s , "foo" )
503503
504504 def test_substring_expand_forward (self ):
505- self .repl .config .autocomplete_mode = 2
505+ self .repl .config .autocomplete_mode = autocomplete . SUBSTRING
506506 self .repl .s = "ba"
507507 self .repl .tab ()
508508 self .assertEqual (self .repl .s , "bar" )
0 commit comments