[TIP] Meta-test methods...

Doug Philips dgou at mac.com
Mon Apr 27 08:18:26 PDT 2009


Early this morning, in a low-caffeine-stupor, I wrote:

>However, right now we have something akin to:
>
>def reset_and_voltage_test(self, reset_action, voltage_level):
>     # return a function that will test the given
>     # reset_action and voltage_level combination interactions.
>
># Using a new naming convention for meta-test-methods:
>def make_tests_for_reset_and_voltage_interactions(self):
>     return [self.reset_and_voltage_test(reset_action, voltage_level)
>                 for reset_action in self.reset_actions()
>                 for voltage_level in self.voltage_levels()]

That was the "after" example, how we -might- use a meta-method.

The "before" example is, what we do now and need to fix:
def test_reset_and_voltage_interactions(self):
    for reset_action in self.reset_actions():
        for voltage_level in self.voltage_levels():
            self.reset_and_voltage_test(reset_action, voltage_level)

# and yes, in the current/"before" code, the worker function does the work, in the potential/"after" code, the worker function returns a function that does the work. :)


    -Doug (now with more wakefulness!)




More information about the testing-in-python mailing list