title: database_table locked during automated tests with Selenium Django
body: <p>I use <code>django==3.1.2</code> and selenium and <code>selenium==3.141.0</code>.</p>
  <p>I have a test file with 12 tests and when I execute them like so:</p>
  <p><code>python3 manage.py test myapp.tests --settings=app.settings_test</code> 2 of the tests fail. When I execute them singly like so</p>
  <p><code>python3 manage.py test myapp.tests.MyTests.test_this --settings=app.settings_test</code> they don't fail.</p>
  <blockquote>
  <p>The errors are usually something like
  django.db.utils.OperationalError: database table is locked:
  visitors_person</p>
  <p>The above exception was the direct cause of the following exception:
  myapp_cars</p>
  </blockquote>
  <p>...</p>
  <blockquote>
  <p>django.core.management.base.CommandError: Database
  file:memorydb_default?mode=memory&amp;cache=shared couldn't be flushed.
  Possible reasons:   * The database isn't running or isn't configured
  correctly.   * At least one of the expected database tables doesn't
  exist.   * The SQL was invalid. Hint: Look at the output of
  'django-admin sqlflush'. That's the SQL this command wasn't able to
  run.</p>
  </blockquote>
  <p>or</p>
  <blockquote>
  <p>django.db.utils.OperationalError: database table is locked:
  myapp_drivers</p>
  </blockquote>
  <p>It always errors on different models of the database.</p>
  <p>My database in <code>settings_test.py</code> looks like this:</p>
  <pre><code>DATABASES['default'] = {
      'ENGINE': 'django.db.backends.sqlite3',
      'NAME':   os.path.join(tempfile.gettempdir(), 'db_test.sqlite3'),
      'OPTIONS': {
          'timeout': 20,
      }
  } 
  </code></pre>
  <p>During these tests I create about 120 entries spread over 12 tests, the fixtures install about 20 entries. So not that much. After googling the error I added the timeout and I added <code>time.sleep(1)</code> after each <code>MyModal.objects.create()</code> to see if this is the reason, but it doesn't help.</p>
  <p>Any ideas?</p>