Skip to content

Commit f5cbb6d

Browse files
authored
Remvoe escape_* functions from pymysql.__all__ (PyMySQL#931)
* .travis -> ci * remove initializedb.sh * Remvoe escape functions from __all__ * fix test * don't use deprecated keyword * fix tests * fix tests * black
1 parent 511b6a2 commit f5cbb6d

File tree

11 files changed

+26
-82
lines changed

11 files changed

+26
-82
lines changed

.github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
mysql -h127.0.0.1 -uroot -e 'create database test2 DEFAULT CHARACTER SET utf8mb4'
7171
mysql -h127.0.0.1 -uroot -e "create user test2 identified ${WITH_PLUGIN} by 'some password'; grant all on test2.* to test2;"
7272
mysql -h127.0.0.1 -uroot -e "create user test2@localhost identified ${WITH_PLUGIN} by 'some password'; grant all on test2.* to test2@localhost;"
73-
cp .travis/docker.json pymysql/tests/databases.json
73+
cp ci/docker.json pymysql/tests/databases.json
7474
7575
- name: Run test
7676
run: |

.travis/database.json

-4
This file was deleted.

.travis/docker.json

-4
This file was deleted.

.travis/initializedb.sh

-54
This file was deleted.

ci/database.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{"host": "localhost", "unix_socket": "/var/run/mysqld/mysqld.sock", "user": "root", "password": "", "database": "test1", "use_unicode": true, "local_infile": true},
3+
{"host": "127.0.0.1", "port": 3306, "user": "test2", "password": "some password", "database": "test2" }
4+
]

ci/docker.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{"host": "127.0.0.1", "port": 3306, "user": "root", "password": "", "database": "test1", "use_unicode": true, "local_infile": true},
3+
{"host": "127.0.0.1", "port": 3306, "user": "test2", "password": "some password", "database": "test2" }
4+
]

docs/source/user/development.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ If you would like to run the test suite, create a database for testing like this
2222
mysql -e 'create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'
2323
mysql -e 'create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'
2424

25-
Then, copy the file ``.travis/database.json`` to ``pymysql/tests/databases.json``
25+
Then, copy the file ``ci/database.json`` to ``pymysql/tests/databases.json``
2626
and edit the new file to match your MySQL configuration::
2727

28-
$ cp .travis/database.json pymysql/tests/databases.json
28+
$ cp ci/database.json pymysql/tests/databases.json
2929
$ $EDITOR pymysql/tests/databases.json
3030

3131
To run all the tests, execute the script ``runtests.py``::

pymysql/__init__.py

-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import sys
2525

2626
from .constants import FIELD_TYPE
27-
from .converters import escape_dict, escape_sequence, escape_string
2827
from .err import (
2928
Warning,
3029
Error,
@@ -177,14 +176,10 @@ def install_as_MySQLdb():
177176
"constants",
178177
"converters",
179178
"cursors",
180-
"escape_dict",
181-
"escape_sequence",
182-
"escape_string",
183179
"get_client_info",
184180
"paramstyle",
185181
"threadsafety",
186182
"version_info",
187183
"install_as_MySQLdb",
188-
"NULL",
189184
"__version__",
190185
]

pymysql/tests/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class PyMySQLTestCase(unittest.TestCase):
2121
"host": "localhost",
2222
"user": "root",
2323
"passwd": "",
24-
"db": "test1",
24+
"database": "test1",
2525
"use_unicode": True,
2626
"local_infile": True,
2727
},
28-
{"host": "localhost", "user": "root", "passwd": "", "db": "test2"},
28+
{"host": "localhost", "user": "root", "passwd": "", "database": "test2"},
2929
]
3030

3131
def mysql_server_is(self, conn, version_tuple):

pymysql/tests/test_connection.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def realtestSocketAuth(self):
142142
with TempUser(
143143
self.connect().cursor(),
144144
TestAuthentication.osuser + "@localhost",
145-
self.databases[0]["db"],
145+
self.databases[0]["database"],
146146
self.socket_plugin_name,
147147
) as u:
148148
c = pymysql.connect(user=TestAuthentication.osuser, **self.db)
@@ -216,7 +216,7 @@ def realTestDialogAuthTwoQuestions(self):
216216
with TempUser(
217217
self.connect().cursor(),
218218
"pymysql_2q@localhost",
219-
self.databases[0]["db"],
219+
self.databases[0]["database"],
220220
"two_questions",
221221
"notverysecret",
222222
) as u:
@@ -258,7 +258,7 @@ def realTestDialogAuthThreeAttempts(self):
258258
with TempUser(
259259
self.connect().cursor(),
260260
"pymysql_3a@localhost",
261-
self.databases[0]["db"],
261+
self.databases[0]["database"],
262262
"three_attempts",
263263
"stillnotverysecret",
264264
) as u:
@@ -353,7 +353,7 @@ def realTestPamAuth(self):
353353
with TempUser(
354354
cur,
355355
TestAuthentication.osuser + "@localhost",
356-
self.databases[0]["db"],
356+
self.databases[0]["database"],
357357
"pam",
358358
os.environ.get("PAMSERVICE"),
359359
) as u:
@@ -392,7 +392,10 @@ def testAuthSHA256(self):
392392
conn = self.connect()
393393
c = conn.cursor()
394394
with TempUser(
395-
c, "pymysql_sha256@localhost", self.databases[0]["db"], "sha256_password"
395+
c,
396+
"pymysql_sha256@localhost",
397+
self.databases[0]["database"],
398+
"sha256_password",
396399
) as u:
397400
if self.mysql_server_is(conn, (5, 7, 0)):
398401
c.execute("SET PASSWORD FOR 'pymysql_sha256'@'localhost' ='Sh@256Pa33'")
@@ -442,8 +445,8 @@ def test_autocommit(self):
442445

443446
def test_select_db(self):
444447
con = self.connect()
445-
current_db = self.databases[0]["db"]
446-
other_db = self.databases[1]["db"]
448+
current_db = self.databases[0]["database"]
449+
other_db = self.databases[1]["database"]
447450

448451
cur = con.cursor()
449452
cur.execute("SELECT database()")
@@ -754,7 +757,7 @@ def test_escape_fallback_encoder(self):
754757
class Custom(str):
755758
pass
756759

757-
mapping = {str: pymysql.escape_string}
760+
mapping = {str: pymysql.converters.escape_string}
758761
self.assertEqual(con.escape(Custom("foobar"), mapping), "'foobar'")
759762

760763
def test_escape_no_default(self):

pymysql/tests/test_issues.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_issue_6(self):
6666
""" exception: TypeError: ord() expected a character, but string of length 0 found """
6767
# ToDo: this test requires access to db 'mysql'.
6868
kwargs = self.databases[0].copy()
69-
kwargs["db"] = "mysql"
69+
kwargs["database"] = "mysql"
7070
conn = pymysql.connect(**kwargs)
7171
c = conn.cursor()
7272
c.execute("select * from user")
@@ -152,7 +152,7 @@ def test_issue_17(self):
152152
"""could not connect mysql use passwod"""
153153
conn = self.connect()
154154
host = self.databases[0]["host"]
155-
db = self.databases[0]["db"]
155+
db = self.databases[0]["database"]
156156
c = conn.cursor()
157157

158158
# grant access to a table to a user with a password

0 commit comments

Comments
 (0)