Exemplo n.º 1
0
    def log_handles_unrepresentable_objects(self):
        ''' Bug #537032: repr(bad_object) when logging is fatal'''
        class Unrepresentable:
            def __repr__(self):
                return self._noSuchAttribute

        level = logging.getLogger('Execution').level
        try:
            logging.getLogger('Execution').setLevel(logging.ERROR)
            ctx = ExecutionContext()
            ctx.store_instance('ugh', Unrepresentable())
        finally:
            logging.getLogger('Execution').setLevel(level)
Exemplo n.º 2
0
 def log_handles_unrepresentable_objects(self):
     ''' Bug #537032: repr(bad_object) when logging is fatal'''
     class Unrepresentable(object):
         def __repr__(self):
             return self._noSuchAttribute
     
     level = logging.getLogger('Execution').level
     try:
         logging.getLogger('Execution').setLevel(logging.ERROR)
         ctx = ExecutionContext()
         ctx.store_instance('ugh', Unrepresentable())
     finally:
         logging.getLogger('Execution').setLevel(level)
Exemplo n.º 3
0
    def stores_libraries(self):
        ''' store_instance(library, value) should put the value with the
        libraries where it can be retrieved by get_library_method(name). 
        libraries should be isolated across execution contexts'''
        mr_death = ExecutionContextBehaviour.DeathKnocksAtTheDoor()
        context = ExecutionContext()
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(None)
        spec.get_library_method('doComeInMrDeath').should_be(None)

        context.store_instance('libraryXYZ', mr_death)
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(mr_death.do_come_in_mr_death)
        spec.get_library_method('doComeInMrDeath').should_be(mr_death.do_come_in_mr_death)

        spec = lancelot.Spec(ExecutionContext())
        spec.get_library_method('do_come_in_mr_death').should_be(None)
        spec.get_library_method('doComeInMrDeath').should_be(None)
        
        context.cleanup_imports()
Exemplo n.º 4
0
    def stores_libraries(self):
        ''' store_instance(library, value) should put the value with the
        libraries where it can be retrieved by get_library_method(name). 
        libraries should be isolated across execution contexts'''
        mr_death = ExecutionContextBehaviour.DeathKnocksAtTheDoor()
        context = ExecutionContext()
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(None)
        spec.get_library_method('doComeInMrDeath').should_be(None)

        context.store_instance('libraryXYZ', mr_death)
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(
            mr_death.do_come_in_mr_death)
        spec.get_library_method('doComeInMrDeath').should_be(
            mr_death.do_come_in_mr_death)

        spec = lancelot.Spec(ExecutionContext())
        spec.get_library_method('do_come_in_mr_death').should_be(None)
        spec.get_library_method('doComeInMrDeath').should_be(None)

        context.cleanup_imports()
Exemplo n.º 5
0
    def gets_library_methods_from_fifo_stack(self):
        ''' Library methods should be retrieved from a fifo stack '''
        class GrimReaperKnocks(ExecutionContextBehaviour.DeathKnocksAtTheDoor):
            def do_come_in_mr_death(self):
                return "I'm afraid we don't have any beer"
        context = ExecutionContext()
        mr_death = ExecutionContextBehaviour.DeathKnocksAtTheDoor()
        reaper = GrimReaperKnocks()
        context.store_instance('library1', mr_death)
        context.store_instance('library2', reaper)
        
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(reaper.do_come_in_mr_death)

        context.store_instance('library2', mr_death)
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(mr_death.do_come_in_mr_death)
        spec.get_library_method('doComeInMrDeath').should_be(mr_death.do_come_in_mr_death)
        
        context.cleanup_imports()
Exemplo n.º 6
0
    def gets_library_methods_from_fifo_stack(self):
        ''' Library methods should be retrieved from a fifo stack '''
        class GrimReaperKnocks(ExecutionContextBehaviour.DeathKnocksAtTheDoor):
            def do_come_in_mr_death(self):
                return "I'm afraid we don't have any beer"

        context = ExecutionContext()
        mr_death = ExecutionContextBehaviour.DeathKnocksAtTheDoor()
        reaper = GrimReaperKnocks()
        context.store_instance('library1', mr_death)
        context.store_instance('library2', reaper)

        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(
            reaper.do_come_in_mr_death)

        context.store_instance('library2', mr_death)
        spec = lancelot.Spec(context)
        spec.get_library_method('do_come_in_mr_death').should_be(
            mr_death.do_come_in_mr_death)
        spec.get_library_method('doComeInMrDeath').should_be(
            mr_death.do_come_in_mr_death)

        context.cleanup_imports()