<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Craig,</p>
    <p>For my suite I've used pytest_make_parameterize_id to auto-create
      id's using the first parameterised value as the id name if that
      parameter is called "_" (just underscore - the Python convention
      for a throwaway variable). It works really well, although would
      need some work for backwards compatibility.<br>
    </p>
    <p>So for example your code of:</p>
    <p>@pytest.mark.parametrize('epsg_code,epsg_broken', [<br>
          [2758, False],  # tmerc<br>
          [2036, True],  # sterea   # failure caused by revert done in
      r22803<br>
          [2046, False],  # tmerc<br>
          <br>
      Which has the test "purpose" as a comment (how I used to do it),
      becomes:</p>
    <p>@pytest.mark.parametrize('_, epsg_code,epsg_broken', [<br>
          ["tmerc", 2758, False],<br>
          ["sterea", 2036, True],   # failure caused by revert done in
      r22803<br>
          ["tmerc - 2nd," 2046, False],<br>
          <br>
      And so on. Then if the test fails you see the (hopefully
      meaningful) "sterea----". The advantage is that the id is there
      with the test rather than trailing it in a separate list that's
      just asking to suffer from bitrot.</p>
    <p>----<br>
    </p>
    <p>If you're interested, the code is simple and basically this:</p>
    <p>def pytest_make_parametrize_id(argname, val):<br>
          """ Create a nice readable test id based on "_".<br>
      <br>
          Doesn't quote as expected and stop at the id alone. Instead it
      keeps going through the rest of the args.<br>
      <br>
          Also keeps track of test numbers so PyCharm/PyTest doesn't
      change their order to semi-alphabetical<br>
      <br>
          :param argname: parameterised arg name<br>
          :param val: parameterised value name<br>
          :return: string suitable for a test name<br>
          """<br>
          # We keep a test_num globally so it works across tests; not
      yet investigated a better way of know when we're on the next test<br>
          global test_num<br>
      <br>
          if argname == '_':<br>
              test_num += 1<br>
      <br>
              # Replace spaces with underscores so that we can run the
      given test individually.<br>
              # Can't do that with spaces in test names.<br>
              name = "{id}={name}".format(id=test_num,
      name=val.replace(' ', '_'))<br>
      <br>
              return name<br>
          else:<br>
              # We don't want any value for any other field.<br>
              # Can't leave it as an empty string because then PyTest
      ignores it.<br>
              return "-"<br>
      <br>
    </p>
    <p>Just a thought.</p>
    <p>Jonathan</p>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 2018-12-10 03:04, Craig de Stigter
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAF1M8pd=dDQNC3u8fDwbB3v3WmCOGGZb6greteFjiwPvXKGDog@mail.gmail.com">
      <div dir="ltr">
        <div>Jonathan</div>
        <div><br>
        </div>
        <div>> it's worth spending a little thought on coming up with
          a scheme for test-ids.</div>
        <div><br>
        </div>
        <div>I've been through the list of parametrized tests and
          tweaked the `ids` kwargs to make them a little more helpful at
          first glance: <a
href="https://github.com/OSGeo/gdal/pull/963/commits/8db599e7bc08b7dc73d81591898ed0f5f4243a58"
            moz-do-not-send="true">https://github.com/OSGeo/gdal/pull/963/commits/8db599e7bc08b7dc73d81591898ed0f5f4243a58</a></div>
        <div><br>
        </div>
        <div>I didn't see any way to use `pytest_make_parametrize_id`
          really; IDs rightly vary enough between tests that I can't see
          that hook being very useful here.<br>
        </div>
        <div><br>
        </div>
        <div>Cheers<br>
        </div>
        <div>Craig de Stigter<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr">On Mon, 10 Dec 2018 at 09:59 jratike80 <<a
            href="mailto:jukka.rahkonen@maanmittauslaitos.fi"
            moz-do-not-send="true">jukka.rahkonen@maanmittauslaitos.fi</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">+0<br>
          <br>
          -Jukka Rahkonen-<br>
          <br>
          <br>
          Even Rouault-2 wrote<br>
          > PSC members,<br>
          > <br>
          > gentle reminder to cast your vote on this.<br>
          > <br>
          > Thanks,<br>
          > <br>
          > Even<br>
          <br>
          <br>
          <br>
          <br>
          <br>
          --<br>
          Sent from: <a
            href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html"
            rel="noreferrer" target="_blank" moz-do-not-send="true">http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html</a><br>
          _______________________________________________<br>
          gdal-dev mailing list<br>
          <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank"
            moz-do-not-send="true">gdal-dev@lists.osgeo.org</a><br>
          <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote>
      </div>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>