44import socket
55from six .moves import range
66
7- from mock import Mock
8-
97try :
108 import unittest2 as unittest
119except ImportError :
1210 import unittest
1311
1412from bpython ._py3compat import py3
1513from bpython import config , repl , cli , autocomplete
16- from bpython .test import MagicIterMock
14+ from bpython .test import MagicIterMock , mock
1715
1816
1917def setup_config (conf ):
@@ -99,7 +97,7 @@ def test_update(self):
9997 self .assertEqual (list (slice ), self .matches )
10098
10199 newmatches = ['string' , 'str' , 'set' ]
102- completer = Mock ()
100+ completer = mock . Mock ()
103101 completer .locate .return_value = (0 , 1 , 's' )
104102 self .matches_iterator .update (1 , 's' , newmatches , completer )
105103
@@ -108,7 +106,7 @@ def test_update(self):
108106 self .assertEqual (list (newslice ), newmatches )
109107
110108 def test_cur_line (self ):
111- completer = Mock ()
109+ completer = mock . Mock ()
112110 completer .locate .return_value = (
113111 0 ,
114112 self .matches_iterator .orig_cursor_offset ,
@@ -363,7 +361,7 @@ def test_atbol(self):
363361 self .assertFalse (self .repl .atbol ())
364362
365363 def test_addstr (self ):
366- self .repl .complete = Mock (True )
364+ self .repl .complete = mock . Mock (True )
367365
368366 self .repl .s = "foo"
369367 self .repl .addstr ("bar" )
@@ -386,11 +384,11 @@ def test_simple_tab_complete(self):
386384 self .repl .matches_iter .__bool__ .return_value = False
387385 else :
388386 self .repl .matches_iter .__nonzero__ .return_value = False
389- self .repl .complete = Mock ()
390- self .repl .print_line = Mock ()
387+ self .repl .complete = mock . Mock ()
388+ self .repl .print_line = mock . Mock ()
391389 self .repl .matches_iter .is_cseq .return_value = False
392- self .repl .show_list = Mock ()
393- self .repl .argspec = Mock ()
390+ self .repl .show_list = mock . Mock ()
391+ self .repl .argspec = mock . Mock ()
394392 self .repl .matches_iter .cur_line .return_value = (None , "foobar" )
395393
396394 self .repl .s = "foo"
@@ -420,22 +418,22 @@ def test_normal_tab(self):
420418 """make sure pressing the tab key will
421419 still in some cases add a tab"""
422420 self .repl .s = ""
423- self .repl .config = Mock ()
421+ self .repl .config = mock . Mock ()
424422 self .repl .config .tab_length = 4
425- self .repl .complete = Mock ()
426- self .repl .print_line = Mock ()
423+ self .repl .complete = mock . Mock ()
424+ self .repl .print_line = mock . Mock ()
427425 self .repl .tab ()
428426 self .assertEqual (self .repl .s , " " )
429427
430428 def test_back_parameter (self ):
431- self .repl .matches_iter = Mock ()
429+ self .repl .matches_iter = mock . Mock ()
432430 self .repl .matches_iter .matches = True
433431 self .repl .matches_iter .previous .return_value = "previtem"
434432 self .repl .matches_iter .is_cseq .return_value = False
435- self .repl .show_list = Mock ()
436- self .repl .argspec = Mock ()
433+ self .repl .show_list = mock . Mock ()
434+ self .repl .argspec = mock . Mock ()
437435 self .repl .matches_iter .cur_line .return_value = (None , "previtem" )
438- self .repl .print_line = Mock ()
436+ self .repl .print_line = mock . Mock ()
439437 self .repl .s = "foo"
440438 self .repl .cpos = 0
441439 self .repl .tab (back = True )
@@ -465,10 +463,10 @@ def test_fuzzy_attribute_tab_complete2(self):
465463 def test_simple_expand (self ):
466464 self .repl .s = "f"
467465 self .cpos = 0
468- self .repl .matches_iter = Mock ()
466+ self .repl .matches_iter = mock . Mock ()
469467 self .repl .matches_iter .is_cseq .return_value = True
470468 self .repl .matches_iter .substitute_cseq .return_value = (3 , "foo" )
471- self .repl .print_line = Mock ()
469+ self .repl .print_line = mock . Mock ()
472470 self .repl .tab ()
473471 self .assertEqual (self .repl .s , "foo" )
474472
0 commit comments