class_docstr: Parameterize a test case::
  
  class TestInt(object):
      @parameterized([
          ("A", 10),
          ("F", 15),
          param("10", 42, base=42)
      ])
      def test_int(self, input, expected, base=16):
          actual = int(input, base=base)
          assert_equal(actual, expected)
  
  @parameterized([
      (2, 3, 5)
      (3, 5, 8),
  ])
  def test_add(a, b, expected):
      assert_equal(a + b, expected)
class_docstr_tok: ["Parameterize","a","test","case",":",":","class","TestInt","(","object",")",":","@","parameterized","(","[","(","``","A","''",",","10",")",",","(","``","F","''",",","15",")",",","param","(","``","10","''",",","42",",","base=42",")","]",")","def","test_int","(","self",",","input",",","expected",",","base=16",")",":","actual","=","int","(","input",",","base=base",")","assert_equal","(","actual",",","expected",")","@","parameterized","(","[","(","2",",","3",",","5",")","(","3",",","5",",","8",")",",","]",")","def","test_add","(","a",",","b",",","expected",")",":","assert_equal","(","a","+","b",",","expected",")"]
docstr: A "brute force" method of parameterizing test cases. Creates new
  test cases and injects them into the namespace that the wrapped
  function is being defined in. Useful for parameterizing tests in
  subclasses of 'UnitTest', where Nose test generators don't work.
  
  :param input: An iterable of values to pass to the test function.
  :param name_func: A function that takes a single argument (the
      value from the input iterable) and returns a string to use as
      the name of the test case. If not provided, the name of the
      test case will be the name of the test function with the
      parameter value appended.
  :param doc_func: A function that takes a single argument (the
      value from the input iterable) and returns a string to use as
      the docstring of the test case. If not provided, the docstring
      of the test case will be the docstring of the test function.
  :param skip_on_empty: If True, the test will be skipped if the
      input iterable is empty. If False, a ValueError will be raised
      if the input iterable is empty.
  :param namespace: The namespace (dict-like) to inject the test cases
      into. If not provided, the namespace of the test function will
      be used.
  
  >>> @parameterized.expand([("foo", 1, 2)])
  ... def test_add1(name, input, expected):
  ...     actual = add1(input)
  ...     assert_equal(actual, expected)
  ...
  >>> locals()
  ... 'test_add1_foo_0': <function ...> ...
  >>>
docstr_tok: ["A","``","brute","force","''","method","of","parameterizing","test","cases",".","Creates","new","test","cases","and","injects","them","into","the","namespace","that","the","wrapped","function","is","being","defined","in",".","Useful","for","parameterizing","tests","in","subclasses","of","'UnitTest","'",",","where","Nose","test","generators","do","n't","work",".",":","param","input",":","An","iterable","of","values","to","pass","to","the","test","function",".",":","param","name_func",":","A","function","that","takes","a","single","argument","(","the","value","from","the","input","iterable",")","and","returns","a","string","to","use","as","the","name","of","the","test","case",".","If","not","provided",",","the","name","of","the","test","case","will","be","the","name","of","the","test","function","with","the","parameter","value","appended",".",":","param","doc_func",":","A","function","that","takes","a","single","argument","(","the","value","from","the","input","iterable",")","and","returns","a","string","to","use","as","the","docstring","of","the","test","case",".","If","not","provided",",","the","docstring","of","the","test","case","will","be","the","docstring","of","the","test","function",".",":","param","skip_on_empty",":","If","True",",","the","test","will","be","skipped","if","the","input","iterable","is","empty",".","If","False",",","a","ValueError","will","be","raised","if","the","input","iterable","is","empty",".",":","param","namespace",":","The","namespace","(","dict-like",")","to","inject","the","test","cases","into",".","If","not","provided",",","the","namespace","of","the","test","function","will","be","used",".",">",">",">","@","parameterized.expand","(","[","(","``","foo","''",",","1",",","2",")","]",")","...","def","test_add1","(","name",",","input",",","expected",")",":","...","actual","=","add1","(","input",")","...","assert_equal","(","actual",",","expected",")","...",">",">",">","locals","(",")","...","'test_add1_foo_0","'",":","<","function","...",">","...",">",">",">"]
code: def expand(
      cls,
      input,
      name_func=None,
      doc_func=None,
      skip_on_empty=False,
      namespace=None,
      **legacy,
  ):
      """A "brute force" method of parameterizing test cases. Creates new
      test cases and injects them into the namespace that the wrapped
      function is being defined in. Useful for parameterizing tests in
      subclasses of 'UnitTest', where Nose test generators don't work.
  
      :param input: An iterable of values to pass to the test function.
      :param name_func: A function that takes a single argument (the
          value from the input iterable) and returns a string to use as
          the name of the test case. If not provided, the name of the
          test case will be the name of the test function with the
          parameter value appended.
      :param doc_func: A function that takes a single argument (the
          value from the input iterable) and returns a string to use as
          the docstring of the test case. If not provided, the docstring
          of the test case will be the docstring of the test function.
      :param skip_on_empty: If True, the test will be skipped if the
          input iterable is empty. If False, a ValueError will be raised
          if the input iterable is empty.
      :param namespace: The namespace (dict-like) to inject the test cases
          into. If not provided, the namespace of the test function will
          be used.
  
      >>> @parameterized.expand([("foo", 1, 2)])
      ... def test_add1(name, input, expected):
      ...     actual = add1(input)
      ...     assert_equal(actual, expected)
      ...
      >>> locals()
      ... 'test_add1_foo_0': <function ...> ...
      >>>
      """
  
      if "testcase_func_name" in legacy:
          warnings.warn(
              "testcase_func_name= is deprecated; use name_func=",
              DeprecationWarning,
              stacklevel=2,
          )
          if not name_func:
              name_func = legacy["testcase_func_name"]
  
      if "testcase_func_doc" in legacy:
          warnings.warn(
              "testcase_func_doc= is deprecated; use doc_func=",
              DeprecationWarning,
              stacklevel=2,
          )
          if not doc_func:
              doc_func = legacy["testcase_func_doc"]
  
      doc_func = doc_func or default_doc_func
      name_func = name_func or default_name_func
  
      def parameterized_expand_wrapper(f, instance=None):
          frame_locals = namespace
          if frame_locals is None:
              frame_locals = inspect.currentframe().f_back.f_locals
  
          parameters = cls.input_as_callable(input)()
  
          if not parameters:
              if not skip_on_empty:
                  raise ValueError(
                      "Parameters iterable is empty (hint: use "
                      "`parameterized.expand([], skip_on_empty=True)` to skip "
                      "this test when the input is empty)"
                  )
              return wraps(f)(skip_on_empty_helper)
  
          digits = len(str(len(parameters) - 1))
          for num, p in enumerate(parameters):
              name = name_func(
                  f,
                  "{num:0>{digits}}".format(digits=digits, num=num),
                  p,
              )
              # If the original function has patches applied by 'mock.patch',
              # re-construct all patches on the just former decoration layer
              # of param_as_standalone_func so as not to share
              # patch objects between new functions
              nf = reapply_patches_if_need(f)
              frame_locals[name] = cls.param_as_standalone_func(
                  p, nf, name
              )
              frame_locals[name].__doc__ = doc_func(f, num, p)
  
          # Delete original patches to prevent new function from evaluating
          # original patching object as well as re-constructed patches.
          delete_patches_if_need(f)
  
          f.__test__ = False
  
      return parameterized_expand_wrapper
  
imports: import re
  import sys
  import inspect
  import warnings
  from typing import Iterable
  from functools import wraps
  from types import MethodType
  from collections import namedtuple
  from unittest import TestCase
label_desc: Use image node_id 8 for calling the parameterized obj's underlying member method code with example usage: obj.expand(cls, input, name_func, doc_func, skip_on_empty, namespace) and returns: parameterized_expand_wrapper, wraps