MCPcopy Index your code
hub / github.com/PyMySQL/PyMySQL / test_escape_string

Method test_escape_string

pymysql/tests/test_connection.py:905–916  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

903
904class TestEscape(base.PyMySQLTestCase):
905 def test_escape_string(self):
906 con = self.connect()
907 cur = con.cursor()
908
909 self.assertEqual(con.escape("foo'bar"), "'foo\\'bar'")
910 # added NO_AUTO_CREATE_USER as not including it in 5.7 generates warnings
911 # mysql-8.0 removes the option however
912 if self.mysql_server_is(con, (8, 0, 0)):
913 cur.execute("SET sql_mode='NO_BACKSLASH_ESCAPES'")
914 else:
915 cur.execute("SET sql_mode='NO_BACKSLASH_ESCAPES,NO_AUTO_CREATE_USER'")
916 self.assertEqual(con.escape("foo'bar"), "'foo''bar'")
917
918 def test_escape_builtin_encoders(self):
919 con = self.connect()

Callers

nothing calls this directly

Calls 5

cursorMethod · 0.80
escapeMethod · 0.80
mysql_server_isMethod · 0.80
executeMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected