from inspect import getdoc

import pytest


class CodeCollector(object):

    def __init__(self):

        self.collected = []

    def __call__(self, f):

        self.collected.append(f)
        return f

    def __iter__(self):

        return iter(self.collected)

    def parametrize(self, test_func):

        return pytest.mark.parametrize('code', self, ids=getdoc)(test_func)

from inspect import getdoc

import pytest


class CodeCollector(object):

    def __init__(self, name='code'):

        self.name = name
        self.collected = []

    def __call__(self, f):

        self.collected.append(f)
        return f

    def __iter__(self):

        return iter(self.collected)

    def parametrize(self, test_func):

        return pytest.mark.parametrize(self.name, self, ids=getdoc)(test_func)

Support argument name in the CodeCollector helper.
Support argument name in the CodeCollector helper.

  from inspect import getdoc
  
  import pytest
  
  
  class CodeCollector(object):
  
-     def __init__(self):
+     def __init__(self, name='code'):
  
+         self.name = name
          self.collected = []
  
      def __call__(self, f):
  
          self.collected.append(f)
          return f
  
      def __iter__(self):
  
          return iter(self.collected)
  
      def parametrize(self, test_func):
  
-         return pytest.mark.parametrize('code', self, ids=getdoc)(test_func)
+         return pytest.mark.parametrize(self.name, self, ids=getdoc)(test_func)
  
Support argument name in the CodeCollector helper.
## Code Before:
from inspect import getdoc

import pytest


class CodeCollector(object):

    def __init__(self):

        self.collected = []

    def __call__(self, f):

        self.collected.append(f)
        return f

    def __iter__(self):

        return iter(self.collected)

    def parametrize(self, test_func):

        return pytest.mark.parametrize('code', self, ids=getdoc)(test_func)

## Instruction:
Support argument name in the CodeCollector helper.
## Code After:
from inspect import getdoc

import pytest


class CodeCollector(object):

    def __init__(self, name='code'):

        self.name = name
        self.collected = []

    def __call__(self, f):

        self.collected.append(f)
        return f

    def __iter__(self):

        return iter(self.collected)

    def parametrize(self, test_func):

        return pytest.mark.parametrize(self.name, self, ids=getdoc)(test_func)
