def test_dispatch(self): """ When L{MethodSuffixOutputer.output} is called with an input and the wrapped object has a method named like I{output_INPUT} where I{INPUT} is the name of the input given, that method is called with the context object given. """ context = object() animals = [] world = AnimalWorld(animals) outputer = MethodSuffixOutputer(world) outputer.output(Output.aardvark, context) self.assertEqual([(Output.aardvark, context)], animals)
def test_dispatch(self): """ When L{MethodSuffixOutputer.output} is called with an input and the wrapped object has a method named like I{output_INPUT} where I{INPUT} is the name of the input given, that method is called with the context object given. """ context = object() animals = [] world = AnimalWorld(animals) outputer = MethodSuffixOutputer(world) outputer.output(Output.aardvark, context) self.assertEqual([(Output.aardvark, context)], animals)
def test_prefix(self): """ If a value is given for the optional second L{MethodSuffixOutputer} initializer argument then it is used instead of C{"output_"} as the method dispatch prefix. """ animals = [] class AlternatePrefixWorld(object): def foobar_AARDVARK(self, context): animals.append(context) context = object() world = AlternatePrefixWorld() outputer = MethodSuffixOutputer(world, "foobar_") outputer.output(Output.aardvark, context) self.assertEqual([context], animals)
def test_prefix(self): """ If a value is given for the optional second L{MethodSuffixOutputer} initializer argument then it is used instead of C{"output_"} as the method dispatch prefix. """ animals = [] class AlternatePrefixWorld(object): def foobar_AARDVARK(self, context): animals.append(context) context = object() world = AlternatePrefixWorld() outputer = MethodSuffixOutputer(world, "foobar_") outputer.output(Output.aardvark, context) self.assertEqual([context], animals)