<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import sys <EOL> import traceback <EOL> import pytest <EOL> import _pytest . _code <EOL> from _pytest . python import transfer_markers <EOL> from _pytest . skipping import MarkEvaluator <EOL> def pytest_pycollect_makeitem ( collector , name , obj ) : <EOL> try : <EOL> if not issubclass ( obj , sys . modules [ "<STR_LIT>" ] . TestCase ) : <EOL> return <EOL> except Exception : <EOL> return <EOL> return UnitTestCase ( name , parent = collector ) <EOL> class UnitTestCase ( pytest . Class ) : <EOL> nofuncargs = True <EOL> def setup ( self ) : <EOL> cls = self . obj <EOL> if getattr ( cls , '<STR_LIT>' , False ) : <EOL> return <EOL> setup = getattr ( cls , '<STR_LIT>' , None ) <EOL> if setup is not None : <EOL> setup ( ) <EOL> teardown = getattr ( cls , '<STR_LIT>' , None ) <EOL> if teardown is not None : <EOL> self . addfinalizer ( teardown ) <EOL> super ( UnitTestCase , self ) . setup ( ) <EOL> def collect ( self ) : <EOL> from unittest import TestLoader <EOL> cls = self . obj <EOL> if not getattr ( cls , "<STR_LIT>" , True ) : <EOL> return <EOL> self . session . _fixturemanager . parsefactories ( self , unittest = True ) <EOL> loader = TestLoader ( ) <EOL> module = self . getparent ( pytest . Module ) . obj <EOL> foundsomething = False <EOL> for name in loader . getTestCaseNames ( self . obj ) : <EOL> x = getattr ( self . obj , name ) <EOL> funcobj = getattr ( x , '<STR_LIT>' , x ) <EOL> transfer_markers ( funcobj , cls , module ) <EOL> yield TestCaseFunction ( name , parent = self ) <EOL> foundsomething = True <EOL> if not foundsomething : <EOL> runtest = getattr ( self . obj , '<STR_LIT>' , None ) <EOL> if runtest is not None : <EOL> ut = sys . modules . get ( "<STR_LIT>" , None ) <EOL> if ut is None or runtest != ut . TestCase . runTest : <EOL> yield TestCaseFunction ( '<STR_LIT>' , parent = self ) <EOL> class TestCaseFunction ( pytest . Function ) : <EOL> _excinfo = None <EOL> def setup ( self ) : <EOL> self . _testcase = self . parent . obj ( self . name ) <EOL> self . _fix_unittest_skip_decorator ( ) <EOL> self . _obj = getattr ( self . _testcase , self . name ) <EOL> if hasattr ( self . _testcase , '<STR_LIT>' ) : <EOL> self . _testcase . setup_method ( self . _obj ) <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . _request . _fillfixtures ( ) <EOL> def _fix_unittest_skip_decorator ( self ) : <EOL> """<STR_LIT>""" <EOL> if sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> : <EOL> setattr ( self . _testcase , "<STR_LIT>" , self . name ) <EOL> def teardown ( self ) : <EOL> if hasattr ( self . _testcase , '<STR_LIT>' ) : <EOL> self . _testcase . teardown_method ( self . _obj ) <EOL> def startTest ( self , testcase ) : <EOL> pass <EOL> def _addexcinfo ( self , rawexcinfo ) : <EOL> rawexcinfo = getattr ( rawexcinfo , '<STR_LIT>' , rawexcinfo ) <EOL> try : <EOL> excinfo = _pytest . _code . ExceptionInfo ( rawexcinfo ) <EOL> except TypeError : <EOL> try : <EOL> try : <EOL> l = traceback . format_exception ( * rawexcinfo ) <EOL> l . insert ( <NUM_LIT:0> , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> pytest . fail ( "<STR_LIT>" . join ( l ) , pytrace = False ) <EOL> except ( pytest . fail . Exception , KeyboardInterrupt ) : <EOL> raise <EOL> except : <EOL> pytest . fail ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( rawexcinfo , ) , pytrace = False ) <EOL> except KeyboardInterrupt : <EOL> raise <EOL> except pytest . fail . Exception : <EOL> excinfo = _pytest . _code . ExceptionInfo ( ) <EOL> self . __dict__ . setdefault ( '<STR_LIT>' , [ ] ) . append ( excinfo ) <EOL> def addError ( self , testcase , rawexcinfo ) : <EOL> self . _addexcinfo ( rawexcinfo ) <EOL> def addFailure ( self , testcase , rawexcinfo ) : <EOL> self . _addexcinfo ( rawexcinfo ) <EOL> def addSkip ( self , testcase , reason ) : <EOL> try : <EOL> pytest . skip ( reason ) <EOL> except pytest . skip . Exception : <EOL> self . _evalskip = MarkEvaluator ( self , '<STR_LIT>' ) <EOL> self . _evalskip . result = True <EOL> self . _addexcinfo ( sys . exc_info ( ) ) <EOL> def addExpectedFailure ( self , testcase , rawexcinfo , reason = "<STR_LIT>" ) : <EOL> try : <EOL> pytest . xfail ( str ( reason ) ) <EOL> except pytest . xfail . Exception : <EOL> self . _addexcinfo ( sys . exc_info ( ) ) <EOL> def addUnexpectedSuccess ( self , testcase , reason = "<STR_LIT>" ) : <EOL> self . _unexpectedsuccess = reason <EOL> def addSuccess ( self , testcase ) : <EOL> pass <EOL> def stopTest ( self , testcase ) : <EOL> pass <EOL> def runtest ( self ) : <EOL> self . _testcase ( result = self ) <EOL> def _prunetraceback ( self , excinfo ) : <EOL> pytest . Function . _prunetraceback ( self , excinfo ) <EOL> traceback = excinfo . traceback . filter ( <EOL> lambda x : not x . frame . f_globals . get ( '<STR_LIT>' ) ) <EOL> if traceback : <EOL> excinfo . traceback = traceback <EOL> @ pytest . hookimpl ( tryfirst = True ) <EOL> def pytest_runtest_makereport ( item , call ) : <EOL> if isinstance ( item , TestCaseFunction ) : <EOL> if item . _excinfo : <EOL> call . excinfo = item . _excinfo . pop ( <NUM_LIT:0> ) <EOL> try : <EOL> del call . result <EOL> except AttributeError : <EOL> pass <EOL> @ pytest . hookimpl ( hookwrapper = True ) <EOL> def pytest_runtest_protocol ( item ) : <EOL> if isinstance ( item , TestCaseFunction ) and '<STR_LIT>' in sys . modules : <EOL> ut = sys . modules [ '<STR_LIT>' ] <EOL> Failure__init__ = ut . Failure . __init__ <EOL> check_testcase_implements_trial_reporter ( ) <EOL> def excstore ( self , exc_value = None , exc_type = None , exc_tb = None , <EOL> captureVars = None ) : <EOL> if exc_value is None : <EOL> self . _rawexcinfo = sys . exc_info ( ) <EOL> else : <EOL> if exc_type is None : <EOL> exc_type = type ( exc_value ) <EOL> self . _rawexcinfo = ( exc_type , exc_value , exc_tb ) <EOL> try : <EOL> Failure__init__ ( self , exc_value , exc_type , exc_tb , <EOL> captureVars = captureVars ) <EOL> except TypeError : <EOL> Failure__init__ ( self , exc_value , exc_type , exc_tb ) <EOL> ut . Failure . __init__ = excstore <EOL> yield <EOL> ut . Failure . __init__ = Failure__init__ <EOL> else : <EOL> yield <EOL> def check_testcase_implements_trial_reporter ( done = [ ] ) : <EOL> if done : <EOL> return <EOL> from zope . interface import classImplements <EOL> from twisted . trial . itrial import IReporter <EOL> classImplements ( TestCaseFunction , IReporter ) <EOL> done . append ( <NUM_LIT:1> ) </s>
