From fde6b1cc6d29adf6afae307063ed7f7975f78730 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 10:26:08 +0900 Subject: [PATCH 1/8] Send coverage report to coveralls --- .github/workflows/test.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 369b5067..c68f7239 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,7 +5,7 @@ on: pull_request: jobs: - build: + test: runs-on: ubuntu-20.04 strategy: matrix: @@ -50,5 +50,24 @@ jobs: cp .travis/docker.json pymysql/tests/databases.json - name: Run test run: | - pip install -U cryptography PyNaCl pytest pytest-cov mock + pip install -U cryptography PyNaCl pytest pytest-cov mock coveralls pytest -v --cov --cov-config .coveragerc pymysql + - name: Report coverage + run: coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.test-name }} + COVERALLS_PARALLEL: true + + coveralls: + name: Finish coveralls + runs-on: ubuntu-20.04 + needs: test + container: python:3-slim + steps: + - name: Finished + run: | + pip3 install --upgrade coveralls + coveralls --finish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From af484a7ad0f50b1985a09f02a1b31b3060df7534 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 10:29:42 +0900 Subject: [PATCH 2/8] fixup --- pymysql/tests/test_cursor.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pymysql/tests/test_cursor.py b/pymysql/tests/test_cursor.py index fb3e8bed..4c9174f5 100644 --- a/pymysql/tests/test_cursor.py +++ b/pymysql/tests/test_cursor.py @@ -30,7 +30,6 @@ def test_cleanup_rows_unbuffered(self): break del cursor - self.safe_gc_collect() c2 = conn.cursor() @@ -48,10 +47,8 @@ def test_cleanup_rows_buffered(self): break del cursor - self.safe_gc_collect() c2 = conn.cursor() - c2.execute("select 1") self.assertEqual( From a024813c082c56d7cc6e59af763658f2d80c9948 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 10:33:06 +0900 Subject: [PATCH 3/8] fixup --- pymysql/connections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymysql/connections.py b/pymysql/connections.py index e426d151..6fd15e13 100644 --- a/pymysql/connections.py +++ b/pymysql/connections.py @@ -341,7 +341,7 @@ def _create_ssl_ctx(self, sslp): elif isinstance(verify_mode_value, bool): ctx.verify_mode = ssl.CERT_REQUIRED if verify_mode_value else ssl.CERT_NONE else: - if isinstance(verify_mode_value, (text_type, str_type)): + if isinstance(verify_mode_value, str): verify_mode_value = verify_mode_value.lower() if verify_mode_value in ("none", "0", "false", "no"): ctx.verify_mode = ssl.CERT_NONE From bf5147900a159bf4ad372f950e34f34bdeaca8b8 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 10:46:21 +0900 Subject: [PATCH 4/8] debug print --- pymysql/cursors.py | 1 + .../thirdparty/test_MySQLdb/capabilities.py | 18 ++++++------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pymysql/cursors.py b/pymysql/cursors.py index 6f72ba35..0de631b6 100644 --- a/pymysql/cursors.py +++ b/pymysql/cursors.py @@ -292,6 +292,7 @@ def scroll(self, value, mode='relative'): self.rownumber = r def _query(self, q): + print(q) conn = self._get_db() self._last_executed = q self._clear_result() diff --git a/pymysql/tests/thirdparty/test_MySQLdb/capabilities.py b/pymysql/tests/thirdparty/test_MySQLdb/capabilities.py index 6be9d1ba..e261a78e 100644 --- a/pymysql/tests/thirdparty/test_MySQLdb/capabilities.py +++ b/pymysql/tests/thirdparty/test_MySQLdb/capabilities.py @@ -8,7 +8,6 @@ from time import time import unittest -PY2 = sys.version_info[0] == 2 class DatabaseTest(unittest.TestCase): @@ -24,10 +23,7 @@ def setUp(self): self.connection = db self.cursor = db.cursor() self.BLOBText = ''.join([chr(i) for i in range(256)] * 100); - if PY2: - self.BLOBUText = unicode().join(unichr(i) for i in range(16834)) - else: - self.BLOBUText = "".join(chr(i) for i in range(16834)) + self.BLOBUText = "".join(chr(i) for i in range(16834)) data = bytearray(range(256)) * 16 self.BLOBBinary = self.db_module.Binary(data) @@ -64,14 +60,12 @@ def new_table_name(self): i = i + 1 def create_table(self, columndefs): + """ + Create a table using a list of column definitions given in columndefs. - """ Create a table using a list of column definitions given in - columndefs. - - generator must be a function taking arguments (row_number, - col_number) returning a suitable data object for insertion - into the table. - + generator must be a function taking arguments (row_number, + col_number) returning a suitable data object for insertion + into the table. """ self.table = self.new_table_name() self.cursor.execute('CREATE TABLE %s (%s) %s' % From 6280ed3b473cebef3c9fc32e72565090dd25e7e7 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 10:53:59 +0900 Subject: [PATCH 5/8] debug print2 --- pymysql/cursors.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pymysql/cursors.py b/pymysql/cursors.py index 0de631b6..6a1a2a15 100644 --- a/pymysql/cursors.py +++ b/pymysql/cursors.py @@ -1,4 +1,5 @@ import re +import traceback from . import err @@ -292,12 +293,15 @@ def scroll(self, value, mode='relative'): self.rownumber = r def _query(self, q): - print(q) conn = self._get_db() self._last_executed = q self._clear_result() - conn.query(q) - self._do_get_result() + try: + conn.query(q) + self._do_get_result() + except: + traceback.print_exc() + print(repr(q)) return self.rowcount def _clear_result(self): From fa5a62619aba9364db14d5a17783ba188411cb03 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 11:03:32 +0900 Subject: [PATCH 6/8] fix --- pymysql/cursors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymysql/cursors.py b/pymysql/cursors.py index 6a1a2a15..1d895263 100644 --- a/pymysql/cursors.py +++ b/pymysql/cursors.py @@ -302,6 +302,7 @@ def _query(self, q): except: traceback.print_exc() print(repr(q)) + raise return self.rowcount def _clear_result(self): From c9fea5e9b0e905c436822f9bb9c5b0c596c29416 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 11:19:22 +0900 Subject: [PATCH 7/8] fix missing escape --- pymysql/converters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymysql/converters.py b/pymysql/converters.py index 0e40eab7..6d1fc9ee 100644 --- a/pymysql/converters.py +++ b/pymysql/converters.py @@ -74,11 +74,11 @@ def escape_string(value, mapping=None): def escape_bytes_prefixed(value, mapping=None): - return "_binary'%s'" % value.decode('ascii', 'surrogateescape') + return "_binary'%s'" % value.decode('ascii', 'surrogateescape').translate(_escape_table) def escape_bytes(value, mapping=None): - return "'%s'" % value.decode('ascii', 'surrogateescape') + return "'%s'" % value.decode('ascii', 'surrogateescape').translate(_escape_table) def escape_str(value, mapping=None): From fce6fce0d20d8a059e157c170c7d6a279a60c02f Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 3 Jan 2021 11:21:03 +0900 Subject: [PATCH 8/8] remove debug print --- pymysql/cursors.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pymysql/cursors.py b/pymysql/cursors.py index 1d895263..a8c52836 100644 --- a/pymysql/cursors.py +++ b/pymysql/cursors.py @@ -1,6 +1,4 @@ import re -import traceback - from . import err @@ -296,13 +294,8 @@ def _query(self, q): conn = self._get_db() self._last_executed = q self._clear_result() - try: - conn.query(q) - self._do_get_result() - except: - traceback.print_exc() - print(repr(q)) - raise + conn.query(q) + self._do_get_result() return self.rowcount def _clear_result(self):