33import os
44import socket
55import sys
6- import unittest
76
87from mock import Mock , MagicMock
98
109try :
11- from unittest import skip
10+ import unittest2 as unittest
1211except ImportError :
13- def skip (f ):
14- return lambda self : None
12+ import unittest
1513
1614py3 = (sys .version_info [0 ] == 3 )
1715
@@ -101,7 +99,7 @@ def test_append(self):
10199
102100 self .assertEqual (self .history .back (), 'print "foo\n "' )
103101
104- @skip ("I don't understand this test" )
102+ @unittest . skip ("I don't understand this test" )
105103 def test_enter (self ):
106104 self .history .enter ('#lastnumber!' )
107105
@@ -278,7 +276,7 @@ def assert_get_source_error_for_current_function(self, func, msg):
278276 def test_current_function (self ):
279277 self .set_input_line ('INPUTLINE' )
280278 self .repl .current_func = collections .MutableSet .add
281- self .assertTrue ("Add an element." in self .repl .get_source_of_current_name ())
279+ self .assertIn ("Add an element." , self .repl .get_source_of_current_name ())
282280
283281 self .assert_get_source_error_for_current_function (
284282 collections .defaultdict .copy , "No source code found for INPUTLINE" )
@@ -295,7 +293,7 @@ def test_current_function(self):
295293 def test_current_line (self ):
296294 self .repl .interp .locals ['a' ] = socket .socket
297295 self .set_input_line ('a' )
298- self .assertTrue ('dup(self)' in self .repl .get_source_of_current_name ())
296+ self .assertIn ('dup(self)' , self .repl .get_source_of_current_name ())
299297
300298#TODO add tests for various failures without using current function
301299
@@ -334,7 +332,7 @@ def test_simple_global_complete(self):
334332 self .assertEqual (self .repl .matches_iter .matches ,
335333 ['def' , 'del' , 'delattr(' , 'dict(' , 'dir(' , 'divmod(' ])
336334
337- @skip ("disabled while non-simple completion is disabled" )
335+ @unittest . skip ("disabled while non-simple completion is disabled" )
338336 def test_substring_global_complete (self ):
339337 self .repl = FakeRepl ({'autocomplete_mode' : autocomplete .SUBSTRING })
340338 self .setInputLine ("time" )
@@ -344,7 +342,7 @@ def test_substring_global_complete(self):
344342 self .assertEqual (self .repl .completer .matches ,
345343 ['RuntimeError(' , 'RuntimeWarning(' ])
346344
347- @skip ("disabled while non-simple completion is disabled" )
345+ @unittest . skip ("disabled while non-simple completion is disabled" )
348346 def test_fuzzy_global_complete (self ):
349347 self .repl = FakeRepl ({'autocomplete_mode' : autocomplete .FUZZY })
350348 self .setInputLine ("doc" )
@@ -368,7 +366,7 @@ def test_simple_attribute_complete(self):
368366 self .assertEqual (self .repl .matches_iter .matches ,
369367 ['Foo.bar' ])
370368
371- @skip ("disabled while non-simple completion is disabled" )
369+ @unittest . skip ("disabled while non-simple completion is disabled" )
372370 def test_substring_attribute_complete (self ):
373371 self .repl = FakeRepl ({'autocomplete_mode' : autocomplete .SUBSTRING })
374372 self .setInputLine ("Foo.az" )
@@ -382,7 +380,7 @@ def test_substring_attribute_complete(self):
382380 self .assertEqual (self .repl .completer .matches ,
383381 ['Foo.baz' ])
384382
385- @skip ("disabled while non-simple completion is disabled" )
383+ @unittest . skip ("disabled while non-simple completion is disabled" )
386384 def test_fuzzy_attribute_complete (self ):
387385 self .repl = FakeRepl ({'autocomplete_mode' : autocomplete .FUZZY })
388386 self .setInputLine ("Foo.br" )
@@ -412,7 +410,7 @@ def test_file_should_not_appear_in_complete(self):
412410 self .setInputLine ("_" )
413411 self .assertTrue (self .repl .complete ())
414412 self .assertTrue (hasattr (self .repl .matches_iter ,'matches' ))
415- self .assertTrue ('__file__' not in self .repl .matches_iter .matches )
413+ self .assertNotIn ('__file__' , self .repl .matches_iter .matches )
416414
417415
418416class TestCliRepl (unittest .TestCase ):
@@ -465,7 +463,7 @@ def test_simple_tab_complete(self):
465463 self .repl .complete .assert_called_with (tab = True )
466464 self .assertEqual (self .repl .s , "foobar" )
467465
468- @skip ("disabled while non-simple completion is disabled" )
466+ @unittest . skip ("disabled while non-simple completion is disabled" )
469467 def test_substring_tab_complete (self ):
470468 self .repl .s = "bar"
471469 self .repl .config .autocomplete_mode = autocomplete .FUZZY
@@ -474,7 +472,7 @@ def test_substring_tab_complete(self):
474472 self .repl .tab ()
475473 self .assertEqual (self .repl .s , "foofoobar" )
476474
477- @skip ("disabled while non-simple completion is disabled" )
475+ @unittest . skip ("disabled while non-simple completion is disabled" )
478476 def test_fuzzy_tab_complete (self ):
479477 self .repl .s = "br"
480478 self .repl .config .autocomplete_mode = autocomplete .FUZZY
@@ -509,7 +507,7 @@ def test_back_parameter(self):
509507 self .assertTrue (self .repl .s , "previtem" )
510508
511509 # Attribute Tests
512- @skip ("disabled while non-simple completion is disabled" )
510+ @unittest . skip ("disabled while non-simple completion is disabled" )
513511 def test_fuzzy_attribute_tab_complete (self ):
514512 """Test fuzzy attribute with no text"""
515513 self .repl .s = "Foo."
@@ -518,7 +516,7 @@ def test_fuzzy_attribute_tab_complete(self):
518516 self .repl .tab ()
519517 self .assertEqual (self .repl .s , "Foo.foobar" )
520518
521- @skip ("disabled while non-simple completion is disabled" )
519+ @unittest . skip ("disabled while non-simple completion is disabled" )
522520 def test_fuzzy_attribute_tab_complete2 (self ):
523521 """Test fuzzy attribute with some text"""
524522 self .repl .s = "Foo.br"
@@ -538,14 +536,14 @@ def test_simple_expand(self):
538536 self .repl .tab ()
539537 self .assertEqual (self .repl .s , "foo" )
540538
541- @skip ("disabled while non-simple completion is disabled" )
539+ @unittest . skip ("disabled while non-simple completion is disabled" )
542540 def test_substring_expand_forward (self ):
543541 self .repl .config .autocomplete_mode = autocomplete .SUBSTRING
544542 self .repl .s = "ba"
545543 self .repl .tab ()
546544 self .assertEqual (self .repl .s , "bar" )
547545
548- @skip ("disabled while non-simple completion is disabled" )
546+ @unittest . skip ("disabled while non-simple completion is disabled" )
549547 def test_fuzzy_expand (self ):
550548 pass
551549
0 commit comments