title: pytest parameterized test with custom id function
body: <p>I have a parameterized test which takes <code>str</code>, and <code>dict</code> as an argument and so the name look pretty weird if I allow pytest to generate ids.</p>
  <p>I want to generate custom ids using a function, however it seems it's not working as intended.</p>
  <pre><code>def id_func(param):
      if isinstance(param, str):
          return param
  
  
  @pytest.mark.parametrize(argnames=('date', 'category_value'),
                           argvalues=[(&quot;2017.01&quot;, {&quot;bills&quot;: &quot;0,10&quot;, &quot;shopping&quot;: &quot;100,90&quot;, &quot;Summe&quot;: &quot;101,00&quot;}),
                                      (&quot;2017.02&quot;, {&quot;bills&quot;: &quot;20,00&quot;, &quot;shopping&quot;: &quot;10,00&quot;, &quot;Summe&quot;: &quot;30,00&quot;})],
                           ids=id_func)
  def test_demo(date, category_value):
      pass
  </code></pre>
  <p>I was thinking it would return something like this</p>
  <pre><code>test_file.py::test_demo[2017.01] PASSED
  test_file.py::test_demo[2017.02] PASSED
  </code></pre>
  <p>but it's returning this.</p>
  <pre><code>test_file.py::test_demo[2017.01-category_value0] PASSED
  test_file.py::test_demo[2017.02-category_value1] PASSED
  </code></pre>
  <p>Could someone tell me what's wrong with this, or is there any way to achieve this?</p>
  <p><strong>Update:</strong></p>
  <p>I realize what's the issue, if_func will be called for each parameter and if I won't return <code>str</code> for any parameter default function will be called.  I have fix but that's also ugly.</p>
  <pre><code>def id_func(param):
      if isinstance(param, str):
          return param
      return &quot; &quot;
  </code></pre>
  <p>Now it returns something like this,</p>
  <pre><code>test_file.py::test_demo[2017.01- ] PASSED
  test_file.py::test_demo[2017.02- ] PASSED
  </code></pre>
  <p><strong>The problem is even If I return empty string (i.e. <code>return &quot;&quot;</code> )it takes the default representation. Could someone let me know why?</strong></p>