Debian Codegraph @

tests/backends/mysql/test_schema.py

raw
1 import unittest
2
3 from django.db import connection
4 from django.test import TestCase
5
6
7 @unittest.skipUnless(connection.vendor == "mysql", "MySQL tests")
8 class SchemaEditorTests(TestCase):
9 def test_quote_value(self):
10 import MySQLdb
11
12 editor = connection.schema_editor()
13 tested_values = [
14 ("string", "'string'"),
15 ("¿Tú hablas inglés?", "'¿Tú hablas inglés?'"),
16 (b"bytes", b"'bytes'"),
17 (42, "42"),
18 (1.754, "1.754e0" if MySQLdb.version_info >= (1, 3, 14) else "1.754"),
19 (False, b"0" if MySQLdb.version_info >= (1, 4, 0) else "0"),
20 ]
21 for value, expected in tested_values:
22 with self.subTest(value=value):
23 self.assertEqual(editor.quote_value(value), expected)