写的测试用例疯狂报错,老师帮我看看
来源:5-7 为模型类-网址-视图编写测试用例
郑天
2022-12-07
Test session starts (platform: linux, Python 3.7.2, pytest 7.1.3, pytest-sugar 0.9.5)
cachedir: .pytest_cache
django: settings: config.settings.test (from ini)
rootdir: /root/devel/zanhu, configfile: pytest.ini
plugins: anyio-3.6.2, Faker-15.3.1, sugar-0.9.5, django-4.5.2, django-test-plus-2.2.1
collecting …
self = <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>
sql = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
params = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
ignored_wrapper_args = (False, {‘connection’: <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f81b6e01be0>, ‘cursor’: <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>})
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)
else:
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84:
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f81b53a0898>
query = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
args = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
def execute(self, query, args=None):
try:
# args is None means no string interpolation
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)“
args = (b”‘Can add \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘add_user’", b"‘Can change \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘change_user’", …)
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, unicode):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, unicode):
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)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
q = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
def _query(self, q):
db = self._get_db()
self._result = None
db.query(q)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312:
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
The above exception was the direct cause of the following exception:
request = <SubRequest ‘_django_setup_unittest’ for >
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f81b63508d0>
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(
request,
django_db_blocker: "_DatabaseBlocker",
) -> Generator[None, None, None]:
"""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.unittest import TestCaseFunction
original_runtest = TestCaseFunction.runtest
def non_debugging_runtest(self) -> None:
self._testcase(result=self)
try:
TestCaseFunction.runtest = non_debugging_runtest # type: ignore[assignment]
request.getfixturevalue("django_db_setup")
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/plugin.py:490:
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/fixtures.py:125: in django_db_setup
**setup_databases_args
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/test/utils.py:183: in setup_databases
serialize=connection.settings_dict[‘TEST’].get(‘SERIALIZE’, True),
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/base/creation.py:79: in create_test_db
run_syncdb=True,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/init.py:181: in call_command
return command.execute(*args, **defaults)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:398: in execute
output = self.handle(*args, **options)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:89: in wrapped
res = handle_func(*args, **kwargs)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/commands/migrate.py:269: in handle
self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/sql.py:48: in emit_post_migrate_signal
**kwargs
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in send
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/contrib/auth/management/init.py:83: in create_permissions
Permission.objects.using(using).bulk_create(perms)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:515: in bulk_create
objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1293: in _batched_insert
self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1270: in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/sql/compiler.py:1416: in execute_sql
cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:66: in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:75: in _execute_with_wrappers
return executor(sql, params, many, context)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/utils.py:90: in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73: in execute
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206: in execute
res = self._query(query)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312: in _query
db.query(q)
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
---------------------------- Captured stdout setup -----------------------------
Operations to perform:
Synchronize unmigrated apps: allauth, compressor, crispy_forms, github, humanize, messages, rest_framework, staticfiles, taskapp
Apply all migrations: account, auth, contenttypes, sessions, sites, socialaccount, thumbnail, users
Synchronizing apps without migrations:
Creating tables…
Running deferred SQL…
Running migrations:
Applying contenttypes.0001_initial… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0001_initial… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying users.0001_initial… OK
Applying account.0001_initial… OK
Applying account.0002_email_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying auth.0012_alter_user_first_name_max_length… OK
Applying sessions.0001_initial… OK
Applying sites.0001_initial… OK
Applying sites.0002_auto_20221129_2311… OK
Applying socialaccount.0001_initial… OK
Applying socialaccount.0002_token_max_lengths… OK
Applying socialaccount.0003_extra_data_default_dict… OK
Applying thumbnail.0001_initial… OK
Applying users.0002_alter_user_first_name… OK
Applying users.0003_auto_20221130_0009… OK
---------------------------- Captured stderr setup -----------------------------
Creating test database for alias ‘default’ (‘test_zanhu02’)…
Got an error creating the test database: (1007, “Can’t create database ‘test_zanhu02’; database exists”)
Destroying old test database for alias ‘default’ (‘test_zanhu02’)…
Operations to perform:
Synchronize unmigrated apps: allauth, compressor, crispy_forms, github, humanize, messages, rest_framework, staticfiles, taskapp
Apply all migrations: account, auth, contenttypes, sessions, sites, socialaccount, thumbnail, users
Synchronizing apps without migrations:
Creating tables…
Running deferred SQL…
Running migrations:
Applying contenttypes.0001_initial… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0001_initial… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying users.0001_initial… OK
Applying account.0001_initial… OK
Applying account.0002_email_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying auth.0012_alter_user_first_name_max_length… OK
Applying sessions.0001_initial… OK
Applying sites.0001_initial… OK
Applying sites.0002_auto_20221129_2311… OK
Applying socialaccount.0001_initial… OK
Applying socialaccount.0002_token_max_lengths… OK
Applying socialaccount.0003_extra_data_default_dict… OK
Applying thumbnail.0001_initial… OK
Applying users.0002_alter_user_first_name… OK
Applying users.0003_auto_20221130_0009… OK
Creating test database for alias ‘default’ (‘test_zanhu02’)…
Got an error creating the test database: (1007, “Can’t create database ‘test_zanhu02’; database exists”)
Destroying old test database for alias ‘default’ (‘test_zanhu02’)…
test setup failed
self = <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>
sql = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
params = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
ignored_wrapper_args = (False, {‘connection’: <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f81b6e01be0>, ‘cursor’: <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>})
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)
else:
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84:
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f81b53a0898>
query = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
args = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
def execute(self, query, args=None):
try:
# args is None means no string interpolation
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)“
args = (b”‘Can add \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘add_user’", b"‘Can change \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘change_user’", …)
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, unicode):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, unicode):
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)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
q = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
def _query(self, q):
db = self._get_db()
self._result = None
db.query(q)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312:
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
The above exception was the direct cause of the following exception:
request = <SubRequest ‘_django_setup_unittest’ for >
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f81b63508d0>
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(
request,
django_db_blocker: "_DatabaseBlocker",
) -> Generator[None, None, None]:
"""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.unittest import TestCaseFunction
original_runtest = TestCaseFunction.runtest
def non_debugging_runtest(self) -> None:
self._testcase(result=self)
try:
TestCaseFunction.runtest = non_debugging_runtest # type: ignore[assignment]
request.getfixturevalue("django_db_setup")
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/plugin.py:490:
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/fixtures.py:125: in django_db_setup
**setup_databases_args
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/test/utils.py:183: in setup_databases
serialize=connection.settings_dict[‘TEST’].get(‘SERIALIZE’, True),
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/base/creation.py:79: in create_test_db
run_syncdb=True,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/init.py:181: in call_command
return command.execute(*args, **defaults)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:398: in execute
output = self.handle(*args, **options)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:89: in wrapped
res = handle_func(*args, **kwargs)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/commands/migrate.py:269: in handle
self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/sql.py:48: in emit_post_migrate_signal
**kwargs
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in send
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/contrib/auth/management/init.py:83: in create_permissions
Permission.objects.using(using).bulk_create(perms)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:515: in bulk_create
objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1293: in _batched_insert
self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1270: in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/sql/compiler.py:1416: in execute_sql
cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:66: in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:75: in _execute_with_wrappers
return executor(sql, params, many, context)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/utils.py:90: in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73: in execute
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206: in execute
res = self._query(query)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312: in _query
db.query(q)
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
――――――――――――――― ERROR at setup of TestUser.test_get_absolute_url ―――――――――――――――
self = <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>
sql = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
params = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
ignored_wrapper_args = (False, {‘connection’: <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f81b6e01be0>, ‘cursor’: <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>})
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)
else:
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84:
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f81b53a0898>
query = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
args = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
def execute(self, query, args=None):
try:
# args is None means no string interpolation
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)“
args = (b”‘Can add \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘add_user’", b"‘Can change \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘change_user’", …)
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, unicode):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, unicode):
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)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
q = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
def _query(self, q):
db = self._get_db()
self._result = None
db.query(q)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312:
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
The above exception was the direct cause of the following exception:
request = <SubRequest ‘_django_setup_unittest’ for >
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f81b63508d0>
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(
request,
django_db_blocker: "_DatabaseBlocker",
) -> Generator[None, None, None]:
"""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.unittest import TestCaseFunction
original_runtest = TestCaseFunction.runtest
def non_debugging_runtest(self) -> None:
self._testcase(result=self)
try:
TestCaseFunction.runtest = non_debugging_runtest # type: ignore[assignment]
request.getfixturevalue("django_db_setup")
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/plugin.py:490:
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/fixtures.py:125: in django_db_setup
**setup_databases_args
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/test/utils.py:183: in setup_databases
serialize=connection.settings_dict[‘TEST’].get(‘SERIALIZE’, True),
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/base/creation.py:79: in create_test_db
run_syncdb=True,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/init.py:181: in call_command
return command.execute(*args, **defaults)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:398: in execute
output = self.handle(*args, **options)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:89: in wrapped
res = handle_func(*args, **kwargs)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/commands/migrate.py:269: in handle
self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/sql.py:48: in emit_post_migrate_signal
**kwargs
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in send
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/contrib/auth/management/init.py:83: in create_permissions
Permission.objects.using(using).bulk_create(perms)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:515: in bulk_create
objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1293: in _batched_insert
self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1270: in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/sql/compiler.py:1416: in execute_sql
cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:66: in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:75: in _execute_with_wrappers
return executor(sql, params, many, context)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/utils.py:90: in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73: in execute
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206: in execute
res = self._query(query)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312: in _query
db.query(q)
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
test setup failed
self = <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>
sql = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
params = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
ignored_wrapper_args = (False, {‘connection’: <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f81b6e01be0>, ‘cursor’: <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>})
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)
else:
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84:
self = <django.db.backends.mysql.base.CursorWrapper object at 0x7f81b53a0898>
query = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
args = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
def execute(self, query, args=None):
try:
# args is None means no string interpolation
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)“
args = (b”‘Can add \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘add_user’", b"‘Can change \xe7\x94\xa8\xe6\x88\xb7’", b’12’, b"‘change_user’", …)
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, unicode):
query = query.encode(db.encoding)
if args is not None:
if isinstance(args, dict):
nargs = {}
for key, item in args.items():
if isinstance(key, unicode):
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)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206:
self = <MySQLdb.cursors.Cursor object at 0x7f81b53a07f0>
q = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
def _query(self, q):
db = self._get_db()
self._result = None
db.query(q)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312:
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
The above exception was the direct cause of the following exception:
request = <SubRequest ‘_django_setup_unittest’ for >
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f81b63508d0>
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(
request,
django_db_blocker: "_DatabaseBlocker",
) -> Generator[None, None, None]:
"""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.unittest import TestCaseFunction
original_runtest = TestCaseFunction.runtest
def non_debugging_runtest(self) -> None:
self._testcase(result=self)
try:
TestCaseFunction.runtest = non_debugging_runtest # type: ignore[assignment]
request.getfixturevalue("django_db_setup")
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/plugin.py:490:
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/pytest_django/fixtures.py:125: in django_db_setup
**setup_databases_args
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/test/utils.py:183: in setup_databases
serialize=connection.settings_dict[‘TEST’].get(‘SERIALIZE’, True),
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/base/creation.py:79: in create_test_db
run_syncdb=True,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/init.py:181: in call_command
return command.execute(*args, **defaults)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:398: in execute
output = self.handle(*args, **options)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/base.py:89: in wrapped
res = handle_func(*args, **kwargs)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/commands/migrate.py:269: in handle
self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/core/management/sql.py:48: in emit_post_migrate_signal
**kwargs
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in send
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/dispatch/dispatcher.py:182: in
for receiver in self._live_receivers(sender)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/contrib/auth/management/init.py:83: in create_permissions
Permission.objects.using(using).bulk_create(perms)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:515: in bulk_create
objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1293: in _batched_insert
self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/query.py:1270: in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/models/sql/compiler.py:1416: in execute_sql
cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:66: in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:75: in _execute_with_wrappers
return executor(sql, params, many, context)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/utils.py:90: in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/utils.py:84: in _execute
return self.cursor.execute(sql, params)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/django/db/backends/mysql/base.py:73: in execute
return self.cursor.execute(query, args)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:206: in execute
res = self._query(query)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/cursors.py:312: in _query
db.query(q)
self = <_mysql.connection open to ‘127.0.0.1’ at 0x2a92638>
query = b"INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (‘Can add \xe7\x94\xa8\xe6\x88\xb7’, 12…’), (‘Can delete \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘delete_user’), (‘Can view \xe7\x94\xa8\xe6\x88\xb7’, 12, ‘view_user’)"
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: (1366, “Incorrect string value: ‘\xE7\x94\xA8\xE6\x88\xB7’ for column ‘name’ at row 1”)
/root/.local/share/virtualenvs/zanhu-OW0Grnnx/lib/python3.7/site-packages/MySQLdb/connections.py:224: OperationalError
――――――――――――――― ERROR at setup of TestUser.test_get_profile_name ―――――――――――――――
self = <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>
sql = 'INSERT INTO auth_permission
(name
, content_type_id
, codename
) VALUES (%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s)'
params = (‘Can add 用户’, 12, ‘add_user’, ‘Can change 用户’, 12, ‘change_user’, …)
ignored_wrapper_args = (False, {‘connection’: <django.db.backends.mysql.base.DatabaseWrapper object at 0x7f81b6e01be0>, ‘cursor’: <django.db.backends.utils.CursorWrapper object at 0x7f81b53a0550>})
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)
else:
return self.cursor.execute(sql, params)
1回答
-
Jack
2022-12-10
您好,能否把测试用例的代码粘贴一下,可能是测试用例里的用户权限不对,导致错中所有执行对sql都是报错 INSERT INTO
auth_permission的问题。
00
相似问题