Skip to content

Commit

Permalink
Update binary parameter test
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel authored and Daniel committed Nov 7, 2018
1 parent a112999 commit 201a65b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/panels/test_sql.py
Expand Up @@ -122,20 +122,21 @@ def test_param_conversion(self):
'["2017-12-22 16:07:01"]'
))

@unittest.skipUnless(connection.vendor not in ('sqlite', 'postgresql'), '')
@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'])

self.assertEqual(len(self.panel._queries), 1)
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 201a65b

Please sign in to comment.