<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I guess I should have been more specific in my question.  This seems
    like a heck of a lot of overhead to ensure your tests run without
    side effects.  Other options that come to mind:<br>
    <ul>
      <li>if your schema is stable, just delete all data in relevant
        tables before starting the test (or all tables, if you must)</li>
      <li>delete all your DB objects, use the same DB</li>
    </ul>
    <p>We use the first method, namely, that a test is responsible for
      clearing any DB objects first, before it is run, if data in those
      objects could possibly interfere with the test.  So, for example:<br>
    </p>
    <ul>
      <li>If a test wants to make sure a record is inserted using a
        record count on the table, then it must delete all records in
        that table before starting (or count the records that exist
        beforehand).</li>
      <li>If a test wants to edit an existing record and make sure the
        edit was successful, then no reason to clear other records in
        the DB.</li>
    </ul>
    <p>I'm just curious what kind of situations you are encountering
      where the overhead of creating a new DB for every test is better
      than one of the above methods (or some variant).<br>
    </p>
    <p>I could see the need for multiple databases if you were running
      tests in parallel.  <br>
    </p>
    <div class="moz-signature">
      <b>Randy Syring</b><br>
      <small>Husband | Father | Redeemed Sinner</small><br>
      <br>
      <i><small>"For what does it profit a man to gain the whole world<br>
          and forfeit his soul?" (Mark 8:36 ESV)</small></i>
      <br>
      <br>
    </div>
    <div class="moz-cite-prefix">On 04/02/2015 11:05 PM, Alexandre
      Conrad wrote:<br>
    </div>
    <blockquote
cite="mid:CAJSNr-KbFewpBctuUk=F2viyAA9vpw6NDkn3Lg35JL48Ne1s6Q@mail.gmail.com"
      type="cite">
      <p dir="ltr">Test isolation by avoiding artifact data potentially
        generated by other tests that didn't cleanup properly for
        whatever reason and could fail subsequent tests.</p>
      <div class="gmail_quote">On Apr 2, 2015 7:13 PM, "Randy Syring"
        &lt;<a moz-do-not-send="true" href="mailto:randy@thesyrings.us">randy@thesyrings.us</a>&gt;
        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> Discussion: what's the
            point of creating a new database for *every* test?<br>
            <div><br>
              <b>Randy Syring</b><br>
              <small>Husband | Father | Redeemed Sinner</small><br>
              <br>
              <i><small>"For what does it profit a man to gain the whole
                  world<br>
                  and forfeit his soul?" (Mark 8:36 ESV)</small></i> <br>
              <br>
            </div>
            <div>On 04/02/2015 09:32 PM, Abe Winter wrote:<br>
            </div>
            <blockquote type="cite">
              <pre>Hi,

I'm presenting pg13, a new python library for SQL mocking. It's fast
enough to create a new pure-python, in-memory DB for each test. It's
not complete or mature but supports enough of the basics to get good
coverage on a simple app.

Performance is around ~200 tests per second on my hardware. This is vs
1 test per second if you're creating a postgres DB per test;
in-process also parallelizes more easily. Sqlite on :memory: can be
quick but sqlite is not feature-compatible other SQL engines and is
hard to modify (90k lines of C). pg13's whole SQL engine is under 1000
lines, pure python, and easy to extend.

More here:

<a moz-do-not-send="true" href="https://github.com/abe-winter/pg13-py" target="_blank">https://github.com/abe-winter/pg13-py</a>

Thanks,

Abe Winter

_______________________________________________
testing-in-python mailing list
<a moz-do-not-send="true" href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a>
<a moz-do-not-send="true" href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a>

</pre>
            </blockquote>
            <br>
          </div>
          <br>
          _______________________________________________<br>
          testing-in-python mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
          <a moz-do-not-send="true"
            href="http://lists.idyll.org/listinfo/testing-in-python"
            target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
          <br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>