<s> from unittest2 . test . support import LoggingResult <EOL> import unittest2 <EOL> class Test_TestSkipping ( unittest2 . TestCase ) : <EOL> def test_skipping ( self ) : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> def test_skip_me ( self ) : <EOL> self . skipTest ( "<STR_LIT>" ) <EOL> events = [ ] <EOL> result = LoggingResult ( events ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> test . run ( result ) <EOL> self . assertEqual ( events , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( result . skipped , [ ( test , "<STR_LIT>" ) ] ) <EOL> class Foo ( unittest2 . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . skipTest ( "<STR_LIT>" ) <EOL> def test_nothing ( self ) : pass <EOL> events = [ ] <EOL> result = LoggingResult ( events ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> test . run ( result ) <EOL> self . assertEqual ( events , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( result . skipped , [ ( test , "<STR_LIT>" ) ] ) <EOL> self . assertEqual ( result . testsRun , <NUM_LIT:1> ) <EOL> def test_skipping_decorators ( self ) : <EOL> op_table = ( ( unittest2 . skipUnless , False , True ) , <EOL> ( unittest2 . skipIf , True , False ) ) <EOL> for deco , do_skip , dont_skip in op_table : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> @ deco ( do_skip , "<STR_LIT>" ) <EOL> def test_skip ( self ) : <EOL> pass <EOL> @ deco ( dont_skip , "<STR_LIT>" ) <EOL> def test_dont_skip ( self ) : <EOL> pass <EOL> test_do_skip = Foo ( "<STR_LIT>" ) <EOL> test_dont_skip = Foo ( "<STR_LIT>" ) <EOL> suite = unittest2 . TestSuite ( [ test_do_skip , test_dont_skip ] ) <EOL> events = [ ] <EOL> result = LoggingResult ( events ) <EOL> suite . run ( result ) <EOL> self . assertEqual ( len ( result . skipped ) , <NUM_LIT:1> ) <EOL> expected = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . assertEqual ( events , expected ) <EOL> self . assertEqual ( result . testsRun , <NUM_LIT:2> ) <EOL> self . assertEqual ( result . skipped , [ ( test_do_skip , "<STR_LIT>" ) ] ) <EOL> self . assertTrue ( result . wasSuccessful ( ) ) <EOL> def test_skip_class ( self ) : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> def test_1 ( self ) : <EOL> record . append ( <NUM_LIT:1> ) <EOL> Foo = unittest2 . skip ( "<STR_LIT>" ) ( Foo ) <EOL> record = [ ] <EOL> result = unittest2 . TestResult ( ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> suite = unittest2 . TestSuite ( [ test ] ) <EOL> suite . run ( result ) <EOL> self . assertEqual ( result . skipped , [ ( test , "<STR_LIT>" ) ] ) <EOL> self . assertEqual ( record , [ ] ) <EOL> def test_expected_failure ( self ) : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> @ unittest2 . expectedFailure <EOL> def test_die ( self ) : <EOL> self . fail ( "<STR_LIT>" ) <EOL> events = [ ] <EOL> result = LoggingResult ( events ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> test . run ( result ) <EOL> self . assertEqual ( events , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( result . expectedFailures [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , test ) <EOL> self . assertTrue ( result . wasSuccessful ( ) ) <EOL> def test_unexpected_success ( self ) : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> @ unittest2 . expectedFailure <EOL> def test_die ( self ) : <EOL> pass <EOL> events = [ ] <EOL> result = LoggingResult ( events ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> test . run ( result ) <EOL> self . assertEqual ( events , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertFalse ( result . failures ) <EOL> self . assertEqual ( result . unexpectedSuccesses , [ test ] ) <EOL> self . assertTrue ( result . wasSuccessful ( ) ) <EOL> def test_skip_doesnt_run_setup ( self ) : <EOL> class Foo ( unittest2 . TestCase ) : <EOL> wasSetUp = False <EOL> wasTornDown = False <EOL> def setUp ( self ) : <EOL> Foo . wasSetUp = True <EOL> def tornDown ( self ) : <EOL> Foo . wasTornDown = True <EOL> @ unittest2 . skip ( '<STR_LIT>' ) <EOL> def test_1 ( self ) : <EOL> pass <EOL> result = unittest2 . TestResult ( ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> suite = unittest2 . TestSuite ( [ test ] ) <EOL> suite . run ( result ) <EOL> self . assertEqual ( result . skipped , [ ( test , "<STR_LIT>" ) ] ) <EOL> self . assertFalse ( Foo . wasSetUp ) <EOL> self . assertFalse ( Foo . wasTornDown ) <EOL> def test_decorated_skip ( self ) : <EOL> def decorator ( func ) : <EOL> def inner ( * a ) : <EOL> return func ( * a ) <EOL> return inner <EOL> class Foo ( unittest2 . TestCase ) : <EOL> @ decorator <EOL> @ unittest2 . skip ( '<STR_LIT>' ) <EOL> def test_1 ( self ) : <EOL> pass <EOL> result = unittest2 . TestResult ( ) <EOL> test = Foo ( "<STR_LIT>" ) <EOL> suite = unittest2 . TestSuite ( [ test ] ) <EOL> suite . run ( result ) <EOL> self . assertEqual ( result . skipped , [ ( test , "<STR_LIT>" ) ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest2 . main ( ) </s>
