This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Yaroslav.Halchenko, abingham, brian.curtin, eric.araujo, eric.snow, exarkun, fperez, michael.foord, nchauvat, ncoghlan, pitrou, r.david.murray
Date 2011-07-21.02:23:28
SpamBayes Score 0.00470107
Marked as misclassified No
Message-id <>
Here's a sketch for a possible decorator factory:

def parameters(params, *, builder=_default_param_builder):
    def make_parameterized_test(f):
        return ParameterizedTest(f, params, builder)
    return make_parameterized_test

(default builder would be the one I sketched earlier)

Example usage:

ExampleParams = namedtuple('ExampleParams', 'x y')
all_cases = [ExampleParams(x, y) for x in range(3) for y in range(3)]

def x_y_naming(name, cases):
    for idx, case in enumerate(cases, start=1):
        x, y = case
        yield ("{}_{}_{}_{}".format(name, idx, x, y), case)

class ExampleTestCase(TestCase):
  def test_example_auto_naming(self, x, y):
      self.assertNotEqual(x, y) # fails sometimes :)

  @parameters(all_cases, builder=x_y_naming)
  def test_example_custom_naming(self, x, y):
      self.assertNotEqual(x, y) # fails sometimes :)

Once defined, you're far better equipped than I am to decide how TestLoader and TestCase can best cooperate to generate appropriate test operations and error messages.
Date User Action Args
2011-07-21 02:23:30ncoghlansetrecipients: + ncoghlan, exarkun, pitrou, eric.araujo, r.david.murray, michael.foord, brian.curtin, fperez, Yaroslav.Halchenko, nchauvat, abingham, eric.snow
2011-07-21 02:23:29ncoghlansetmessageid: <>
2011-07-21 02:23:29ncoghlanlinkissue7897 messages
2011-07-21 02:23:28ncoghlancreate