You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon upgrading pytest-xdist to 2.0.0 (and pytest-cov to 2.10.1 for compatibility), pytest-django fails to setup the test database.
Highlights of the traceback (some purgatory where test_circle database can't be created because it exists and can't be dropped because it doesn't exist):
except Exception as e:
self.log('Got an error recreating the test database: %s' % e)
> sys.exit(2)
E SystemExit: 2
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:200: SystemExit
Full traceback:
failed on setup with "SystemExit: 2"
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'CREATE DATABASE `test_circle` ', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f773eb67e80>
query = 'CREATE DATABASE `test_circle` ', args = None
def execute(self, query, args=None):
try:
# args is None means no string interpolation
> return self.cursor.execute(query, args)
venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
query = b'CREATE DATABASE `test_circle` ', args = None
def execute(self, query, args=None):
"""Execute a query.
query -- string, query to execute on server
args -- optional sequence or mapping, parameters to use with query.
Note: If args is a sequence, then %s must be used as the
parameter placeholder in the query. If a mapping is used,
%(key)s must be used as the placeholder.
Returns integer represents rows affected, if any
"""
while self.nextset():
pass
db = self._get_db()
if isinstance(query, str):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, str):
key = key.encode(db.encoding)
nargs[key] = db.literal(item)
args = nargs
else:
args = tuple(map(db.literal, args))
try:
query = query % args
except TypeError as m:
raise ProgrammingError(str(m))
assert isinstance(query, (bytes, bytearray))
> res = self._query(query)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:206:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
q = b'CREATE DATABASE `test_circle` '
def _query(self, q):
db = self._get_db()
self._result = None
> db.query(q)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:319:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_mysql.connection closed at 0x55f66195d6d8>
query = b'CREATE DATABASE `test_circle` '
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
> _mysql.connection.query(self, query)
E MySQLdb._exceptions.ProgrammingError: (1007, "Can't create database 'test_circle'; database exists")
venv/lib/python3.6/site-packages/MySQLdb/connections.py:259: ProgrammingError
The above exception was the direct cause of the following exception:
self = <django.db.backends.mysql.creation.DatabaseCreation object at 0x7f76defa6ba8>
verbosity = 0, autoclobber = True, keepdb = False
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
"""
Internal implementation - create the test db tables.
"""
test_database_name = self._get_test_db_name()
test_db_params = {
'dbname': self.connection.ops.quote_name(test_database_name),
'suffix': self.sql_table_creation_suffix(),
}
# Create the test database and connect to it.
with self._nodb_cursor() as cursor:
try:
> self._execute_create_test_db(cursor, test_db_params, keepdb)
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:178:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.creation.DatabaseCreation object at 0x7f76defa6ba8>
cursor = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
parameters = {'dbname': '`test_circle`', 'suffix': ''}, keepdb = False
def _execute_create_test_db(self, cursor, parameters, keepdb=False):
try:
> super()._execute_create_test_db(cursor, parameters, keepdb)
venv/lib/python3.6/site-packages/django/db/backends/mysql/creation.py:22:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.creation.DatabaseCreation object at 0x7f76defa6ba8>
cursor = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
parameters = {'dbname': '`test_circle`', 'suffix': ''}, keepdb = False
def _execute_create_test_db(self, cursor, parameters, keepdb=False):
> cursor.execute('CREATE DATABASE %(dbname)s %(suffix)s' % parameters)
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:164:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'CREATE DATABASE `test_circle` ', params = None
def execute(self, sql, params=None):
> return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'CREATE DATABASE `test_circle` ', params = None, many = False
executor = <bound method CursorWrapper._execute of <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>>
def _execute_with_wrappers(self, sql, params, many, executor):
context = {'connection': self.db, 'cursor': self}
for wrapper in reversed(self.db.execute_wrappers):
executor = functools.partial(wrapper, executor)
> return executor(sql, params, many, context)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'CREATE DATABASE `test_circle` ', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.utils.DatabaseErrorWrapper object at 0x7f773eb7c780>
exc_type = <class 'MySQLdb._exceptions.ProgrammingError'>
exc_value = ProgrammingError(1007, "Can't create database 'test_circle'; database exists")
traceback = <traceback object at 0x7f773ea14648>
def __exit__(self, exc_type, exc_value, traceback):
if exc_type is None:
return
for dj_exc_type in (
DataError,
OperationalError,
IntegrityError,
InternalError,
ProgrammingError,
NotSupportedError,
DatabaseError,
InterfaceError,
Error,
):
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
if issubclass(exc_type, db_exc_type):
dj_exc_value = dj_exc_type(*exc_value.args)
# Only set the 'errors_occurred' flag for errors that may make
# the connection unusable.
if dj_exc_type not in (DataError, IntegrityError):
self.wrapper.errors_occurred = True
> raise dj_exc_value.with_traceback(traceback) from exc_value
venv/lib/python3.6/site-packages/django/db/utils.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'CREATE DATABASE `test_circle` ', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f773eb67e80>
query = 'CREATE DATABASE `test_circle` ', args = None
def execute(self, query, args=None):
try:
# args is None means no string interpolation
> return self.cursor.execute(query, args)
venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
query = b'CREATE DATABASE `test_circle` ', args = None
def execute(self, query, args=None):
"""Execute a query.
query -- string, query to execute on server
args -- optional sequence or mapping, parameters to use with query.
Note: If args is a sequence, then %s must be used as the
parameter placeholder in the query. If a mapping is used,
%(key)s must be used as the placeholder.
Returns integer represents rows affected, if any
"""
while self.nextset():
pass
db = self._get_db()
if isinstance(query, str):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, str):
key = key.encode(db.encoding)
nargs[key] = db.literal(item)
args = nargs
else:
args = tuple(map(db.literal, args))
try:
query = query % args
except TypeError as m:
raise ProgrammingError(str(m))
assert isinstance(query, (bytes, bytearray))
> res = self._query(query)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:206:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
q = b'CREATE DATABASE `test_circle` '
def _query(self, q):
db = self._get_db()
self._result = None
> db.query(q)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:319:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_mysql.connection closed at 0x55f66195d6d8>
query = b'CREATE DATABASE `test_circle` '
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
> _mysql.connection.query(self, query)
E django.db.utils.ProgrammingError: (1007, "Can't create database 'test_circle'; database exists")
venv/lib/python3.6/site-packages/MySQLdb/connections.py:259: ProgrammingError
During handling of the above exception, another exception occurred:
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'DROP DATABASE `test_circle`', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f773eb67e80>
query = 'DROP DATABASE `test_circle`', args = None
def execute(self, query, args=None):
try:
# args is None means no string interpolation
> return self.cursor.execute(query, args)
venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
query = b'DROP DATABASE `test_circle`', args = None
def execute(self, query, args=None):
"""Execute a query.
query -- string, query to execute on server
args -- optional sequence or mapping, parameters to use with query.
Note: If args is a sequence, then %s must be used as the
parameter placeholder in the query. If a mapping is used,
%(key)s must be used as the placeholder.
Returns integer represents rows affected, if any
"""
while self.nextset():
pass
db = self._get_db()
if isinstance(query, str):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, str):
key = key.encode(db.encoding)
nargs[key] = db.literal(item)
args = nargs
else:
args = tuple(map(db.literal, args))
try:
query = query % args
except TypeError as m:
raise ProgrammingError(str(m))
assert isinstance(query, (bytes, bytearray))
> res = self._query(query)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:206:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
q = b'DROP DATABASE `test_circle`'
def _query(self, q):
db = self._get_db()
self._result = None
> db.query(q)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:319:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_mysql.connection closed at 0x55f66195d6d8>
query = b'DROP DATABASE `test_circle`'
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
> _mysql.connection.query(self, query)
E MySQLdb._exceptions.OperationalError: (1008, "Can't drop database 'test_circle'; database doesn't exist")
venv/lib/python3.6/site-packages/MySQLdb/connections.py:259: OperationalError
The above exception was the direct cause of the following exception:
self = <django.db.backends.mysql.creation.DatabaseCreation object at 0x7f76defa6ba8>
verbosity = 0, autoclobber = True, keepdb = False
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
"""
Internal implementation - create the test db tables.
"""
test_database_name = self._get_test_db_name()
test_db_params = {
'dbname': self.connection.ops.quote_name(test_database_name),
'suffix': self.sql_table_creation_suffix(),
}
# Create the test database and connect to it.
with self._nodb_cursor() as cursor:
try:
self._execute_create_test_db(cursor, test_db_params, keepdb)
except Exception as e:
# if we want to keep the db, then no need to do any of the below,
# just return and skip it all.
if keepdb:
return test_database_name
self.log('Got an error creating the test database: %s' % e)
if not autoclobber:
confirm = input(
"Type 'yes' if you would like to try deleting the test "
"database '%s', or 'no' to cancel: " % test_database_name)
if autoclobber or confirm == 'yes':
try:
if verbosity >= 1:
self.log('Destroying old test database for alias %s...' % (
self._get_database_display_str(verbosity, test_database_name),
))
> cursor.execute('DROP DATABASE %(dbname)s' % test_db_params)
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'DROP DATABASE `test_circle`', params = None
def execute(self, sql, params=None):
> return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'DROP DATABASE `test_circle`', params = None, many = False
executor = <bound method CursorWrapper._execute of <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>>
def _execute_with_wrappers(self, sql, params, many, executor):
context = {'connection': self.db, 'cursor': self}
for wrapper in reversed(self.db.execute_wrappers):
executor = functools.partial(wrapper, executor)
> return executor(sql, params, many, context)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'DROP DATABASE `test_circle`', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.utils.DatabaseErrorWrapper object at 0x7f773eb7c780>
exc_type = <class 'MySQLdb._exceptions.OperationalError'>
exc_value = OperationalError(1008, "Can't drop database 'test_circle'; database doesn't exist")
traceback = <traceback object at 0x7f773ea14288>
def __exit__(self, exc_type, exc_value, traceback):
if exc_type is None:
return
for dj_exc_type in (
DataError,
OperationalError,
IntegrityError,
InternalError,
ProgrammingError,
NotSupportedError,
DatabaseError,
InterfaceError,
Error,
):
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
if issubclass(exc_type, db_exc_type):
dj_exc_value = dj_exc_type(*exc_value.args)
# Only set the 'errors_occurred' flag for errors that may make
# the connection unusable.
if dj_exc_type not in (DataError, IntegrityError):
self.wrapper.errors_occurred = True
> raise dj_exc_value.with_traceback(traceback) from exc_value
venv/lib/python3.6/site-packages/django/db/utils.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>
sql = 'DROP DATABASE `test_circle`', params = None
ignored_wrapper_args = (False, {'connection': <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f773eb7c630>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f773eb67eb8>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
# params default might be backend specific.
> return self.cursor.execute(sql)
venv/lib/python3.6/site-packages/django/db/backends/utils.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f773eb67e80>
query = 'DROP DATABASE `test_circle`', args = None
def execute(self, query, args=None):
try:
# args is None means no string interpolation
> return self.cursor.execute(query, args)
venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
query = b'DROP DATABASE `test_circle`', args = None
def execute(self, query, args=None):
"""Execute a query.
query -- string, query to execute on server
args -- optional sequence or mapping, parameters to use with query.
Note: If args is a sequence, then %s must be used as the
parameter placeholder in the query. If a mapping is used,
%(key)s must be used as the placeholder.
Returns integer represents rows affected, if any
"""
while self.nextset():
pass
db = self._get_db()
if isinstance(query, str):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, str):
key = key.encode(db.encoding)
nargs[key] = db.literal(item)
args = nargs
else:
args = tuple(map(db.literal, args))
try:
query = query % args
except TypeError as m:
raise ProgrammingError(str(m))
assert isinstance(query, (bytes, bytearray))
> res = self._query(query)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:206:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MySQLdb.cursors.Cursor object at 0x7f773eb67e10>
q = b'DROP DATABASE `test_circle`'
def _query(self, q):
db = self._get_db()
self._result = None
> db.query(q)
venv/lib/python3.6/site-packages/MySQLdb/cursors.py:319:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_mysql.connection closed at 0x55f66195d6d8>
query = b'DROP DATABASE `test_circle`'
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
> _mysql.connection.query(self, query)
E django.db.utils.OperationalError: (1008, "Can't drop database 'test_circle'; database doesn't exist")
venv/lib/python3.6/site-packages/MySQLdb/connections.py:259: OperationalError
During handling of the above exception, another exception occurred:
request = <SubRequest '_django_setup_unittest' for <TestCaseFunction test_non_place_attributes>>
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f7745582128>
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(request, django_db_blocker):
"""Setup a django unittest, internal to pytest-django."""
if not django_settings_is_configured() or not is_django_unittest(request):
yield
return
# Fix/patch pytest.
# Before pytest 5.4: https://github.com/pytest-dev/pytest/issues/5991
# After pytest 5.4: https://github.com/pytest-dev/pytest-django/issues/824
from _pytest.monkeypatch import MonkeyPatch
def non_debugging_runtest(self):
self._testcase(result=self)
mp_debug = MonkeyPatch()
mp_debug.setattr("_pytest.unittest.TestCaseFunction.runtest", non_debugging_runtest)
> request.getfixturevalue("django_db_setup")
venv/lib/python3.6/site-packages/pytest_django/plugin.py:534:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.6/site-packages/pytest_django/fixtures.py:108: in django_db_setup
**setup_databases_args
venv/lib/python3.6/site-packages/django/test/utils.py:174: in setup_databases
serialize=connection.settings_dict['TEST'].get('SERIALIZE', True),
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:55: in create_test_db
self._create_test_db(verbosity, autoclobber, keepdb)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.mysql.creation.DatabaseCreation object at 0x7f76defa6ba8>
verbosity = 0, autoclobber = True, keepdb = False
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
"""
Internal implementation - create the test db tables.
"""
test_database_name = self._get_test_db_name()
test_db_params = {
'dbname': self.connection.ops.quote_name(test_database_name),
'suffix': self.sql_table_creation_suffix(),
}
# Create the test database and connect to it.
with self._nodb_cursor() as cursor:
try:
self._execute_create_test_db(cursor, test_db_params, keepdb)
except Exception as e:
# if we want to keep the db, then no need to do any of the below,
# just return and skip it all.
if keepdb:
return test_database_name
self.log('Got an error creating the test database: %s' % e)
if not autoclobber:
confirm = input(
"Type 'yes' if you would like to try deleting the test "
"database '%s', or 'no' to cancel: " % test_database_name)
if autoclobber or confirm == 'yes':
try:
if verbosity >= 1:
self.log('Destroying old test database for alias %s...' % (
self._get_database_display_str(verbosity, test_database_name),
))
cursor.execute('DROP DATABASE %(dbname)s' % test_db_params)
self._execute_create_test_db(cursor, test_db_params, keepdb)
except Exception as e:
self.log('Got an error recreating the test database: %s' % e)
> sys.exit(2)
E SystemExit: 2
venv/lib/python3.6/site-packages/django/db/backends/base/creation.py:200: SystemExit
The text was updated successfully, but these errors were encountered:
jshields
changed the title
Database setup broken with pytest-xdist 2.0.0django_db_setup fixture broken with pytest-xdist 2.0.0
Aug 17, 2020
Upon upgrading pytest-xdist to 2.0.0 (and pytest-cov to 2.10.1 for compatibility), pytest-django fails to setup the test database.
Highlights of the traceback (some purgatory where
test_circle
database can't be created because it exists and can't be dropped because it doesn't exist):Full traceback:
The text was updated successfully, but these errors were encountered: