Skip to content

Commit

Permalink
Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel authored and Daniel committed Nov 7, 2018
1 parent cd49e0f commit 6862752
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion debug_toolbar/panels/sql/tracking.py
Expand Up @@ -93,7 +93,7 @@ def _quote_expr(self, element):
except DjangoUnicodeDecodeError:
return repr(element)
elif isinstance(element, six.binary_type):
return '(binary data)'
return "(binary data)"
else:
return repr(element)

Expand Down
20 changes: 13 additions & 7 deletions tests/panels/test_sql.py
Expand Up @@ -113,23 +113,29 @@ def test_param_conversion(self):
('["Foo", true, false]', "[10, 1]", '["2017-12-22 16:07:01"]'),
)

@unittest.skipIf(connection.vendor in ('sqlite', 'postgresql'),
'Mixing bytestrings and text is not allowed on PostgreSQL and'
'SQLite')
@unittest.skipIf(
connection.vendor in ("sqlite", "postgresql"),
"Mixing bytestrings and text is not allowed on PostgreSQL and SQLite"
)
def test_binary_param_force_text(self):
self.assertEqual(len(self.panel._queries), 0)

with connection.cursor() as cursor:
cursor.execute("SELECT * FROM auth_user WHERE username = %s", [b'\xff'])
cursor.execute(
"SELECT * FROM auth_user WHERE username = %s",
[b'\xff']
)

self.assertEqual(len(self.panel._queries), 1)
self.assertEqual(self.panel._queries[0][1]['sql'],
"SELECT * FROM auth_user WHERE username = '\ufffd'")
self.assertEqual(
self.panel._queries[0][1]["sql"],
"SELECT * FROM auth_user WHERE username = '\ufffd'"
)

self.panel.process_response(self.request, self.response)
self.panel.generate_stats(self.request, self.response)

@unittest.skipUnless(connection.vendor != 'sqlite', 'Test invalid for SQLite')
@unittest.skipUnless(connection.vendor != "sqlite", "Test invalid for SQLite")
def test_raw_query_param_conversion(self):
self.assertEqual(len(self.panel._queries), 0)

Expand Down

0 comments on commit 6862752

Please sign in to comment.