commit python-PyMySQL for openSUSE:Factory
Hello community, here is the log from the commit of package python-PyMySQL for openSUSE:Factory checked in at 2016-12-08 00:29:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-PyMySQL (Old) and /work/SRC/openSUSE:Factory/.python-PyMySQL.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-PyMySQL" Changes: -------- --- /work/SRC/openSUSE:Factory/python-PyMySQL/python-PyMySQL.changes 2016-06-07 23:49:27.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-PyMySQL.new/python-PyMySQL.changes 2016-12-08 00:29:16.000000000 +0100 @@ -1,0 +2,13 @@ +Tue Nov 15 10:30:55 UTC 2016 - dmueller@suse.com + +- update to 0.7.6: + * Fix SELECT JSON type cause UnicodeError + * Avoid float convertion while parsing microseconds + * Warning has number + * SSCursor supports warnings + * Fix exception raised while importing when getpwuid() fails (#472) + * SSCursor supports LOAD DATA LOCAL INFILE (#473) + * Fix encoding error happen for JSON type (#477) + * Fix test fail on Python 2.7 and MySQL 5.7 (#478) + +------------------------------------------------------------------- Old: ---- PyMySQL-0.7.4.tar.gz New: ---- PyMySQL-0.7.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-PyMySQL.spec ++++++ --- /var/tmp/diff_new_pack.RPoUUi/_old 2016-12-08 00:29:17.000000000 +0100 +++ /var/tmp/diff_new_pack.RPoUUi/_new 2016-12-08 00:29:17.000000000 +0100 @@ -17,7 +17,7 @@ Name: python-PyMySQL -Version: 0.7.4 +Version: 0.7.6 Release: 0 Summary: Pure Python MySQL Driver License: MIT ++++++ PyMySQL-0.7.4.tar.gz -> PyMySQL-0.7.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/CHANGELOG new/PyMySQL-0.7.6/CHANGELOG --- old/PyMySQL-0.7.4/CHANGELOG 2016-05-26 06:13:18.000000000 +0200 +++ new/PyMySQL-0.7.6/CHANGELOG 2016-07-29 05:21:41.000000000 +0200 @@ -1,5 +1,23 @@ # Changes +## 0.7.6 + +Release date: 2016-07-29 + +* Fix SELECT JSON type cause UnicodeError +* Avoid float convertion while parsing microseconds +* Warning has number +* SSCursor supports warnings + +## 0.7.5 + +Release date: 2016-06-28 + +* Fix exception raised while importing when getpwuid() fails (#472) +* SSCursor supports LOAD DATA LOCAL INFILE (#473) +* Fix encoding error happen for JSON type (#477) +* Fix test fail on Python 2.7 and MySQL 5.7 (#478) + ## 0.7.4 Release date: 2016-05-26 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/PKG-INFO new/PyMySQL-0.7.6/PKG-INFO --- old/PyMySQL-0.7.4/PKG-INFO 2016-05-26 06:14:55.000000000 +0200 +++ new/PyMySQL-0.7.6/PKG-INFO 2016-07-29 05:27:02.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: PyMySQL -Version: 0.7.4 +Version: 0.7.6 Summary: Pure Python MySQL Driver Home-page: https://github.com/PyMySQL/PyMySQL/ Author: INADA Naoki diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/PyMySQL.egg-info/PKG-INFO new/PyMySQL-0.7.6/PyMySQL.egg-info/PKG-INFO --- old/PyMySQL-0.7.4/PyMySQL.egg-info/PKG-INFO 2016-05-26 06:14:54.000000000 +0200 +++ new/PyMySQL-0.7.6/PyMySQL.egg-info/PKG-INFO 2016-07-29 05:27:02.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: PyMySQL -Version: 0.7.4 +Version: 0.7.6 Summary: Pure Python MySQL Driver Home-page: https://github.com/PyMySQL/PyMySQL/ Author: INADA Naoki diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/README.rst new/PyMySQL-0.7.6/README.rst --- old/PyMySQL-0.7.4/README.rst 2016-05-26 06:05:45.000000000 +0200 +++ new/PyMySQL-0.7.6/README.rst 2016-07-28 17:42:45.000000000 +0200 @@ -15,7 +15,8 @@ PyMySQL ======= -.. contents:: +.. contents:: Table of Contents + :local: This package contains a pure-Python MySQL client library. The goal of PyMySQL is to be a drop-in replacement for MySQLdb and work on CPython, PyPy and IronPython. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/__init__.py new/PyMySQL-0.7.6/pymysql/__init__.py --- old/PyMySQL-0.7.4/pymysql/__init__.py 2016-05-26 06:14:03.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/__init__.py 2016-07-29 05:21:53.000000000 +0200 @@ -33,7 +33,7 @@ DateFromTicks, TimeFromTicks, TimestampFromTicks -VERSION = (0, 7, 4, None) +VERSION = (0, 7, 6, None) threadsafety = 1 apilevel = "2.0" paramstyle = "pyformat" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/charset.py new/PyMySQL-0.7.6/pymysql/charset.py --- old/PyMySQL-0.7.4/pymysql/charset.py 2015-09-29 17:10:42.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/charset.py 2016-07-28 17:42:45.000000000 +0200 @@ -11,6 +11,10 @@ self.id, self.name, self.collation = id, name, collation self.is_default = is_default == 'Yes' + def __repr__(self): + return "Charset(id=%s, name=%r, collation=%r)" % ( + self.id, self.name, self.collation) + @property def encoding(self): name = self.name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/connections.py new/PyMySQL-0.7.6/pymysql/connections.py --- old/PyMySQL-0.7.4/pymysql/connections.py 2016-05-26 06:05:45.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/connections.py 2016-07-28 17:42:45.000000000 +0200 @@ -35,7 +35,8 @@ import getpass DEFAULT_USER = getpass.getuser() del getpass -except ImportError: +except (ImportError, KeyError): + # KeyError occurs when there's no entry in OS database for a current user. DEFAULT_USER = None @@ -405,9 +406,9 @@ def __init__(self, data, encoding): MysqlPacket.__init__(self, data, encoding) - self.__parse_field_descriptor(encoding) + self._parse_field_descriptor(encoding) - def __parse_field_descriptor(self, encoding): + def _parse_field_descriptor(self, encoding): """Parse the 'Field Descriptor' (Metadata) packet. This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0). @@ -1318,6 +1319,10 @@ self._read_ok_packet(first_packet) self.unbuffered_active = False self.connection = None + elif first_packet.is_load_local_packet(): + self._read_load_local_packet(first_packet) + self.unbuffered_active = False + self.connection = None else: self.field_count = first_packet.read_length_encoded_integer() self._get_descriptions() @@ -1427,21 +1432,30 @@ self.fields = [] self.converters = [] use_unicode = self.connection.use_unicode + conn_encoding = self.connection.encoding description = [] + for i in range_type(self.field_count): field = self.connection._read_packet(FieldDescriptorPacket) self.fields.append(field) description.append(field.description()) field_type = field.type_code if use_unicode: - if field_type in TEXT_TYPES: - charset = charset_by_id(field.charsetnr) - if charset.is_binary: + if field_type == FIELD_TYPE.JSON: + # When SELECT from JSON column: charset = binary + # When SELECT CAST(... AS JSON): charset = connection encoding + # This behavior is different from TEXT / BLOB. + # We should decode result by connection encoding regardless charsetnr. + # See https://github.com/PyMySQL/PyMySQL/issues/488 + encoding = conn_encoding # SELECT CAST(... AS JSON) + elif field_type in TEXT_TYPES: + if field.charsetnr == 63: # binary # TEXTs with charset=binary means BINARY types. encoding = None else: - encoding = charset.encoding + encoding = conn_encoding else: + # Integers, Dates and Times, and other basic data is encoded in ascii encoding = 'ascii' else: encoding = None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/constants/FIELD_TYPE.py new/PyMySQL-0.7.6/pymysql/constants/FIELD_TYPE.py --- old/PyMySQL-0.7.4/pymysql/constants/FIELD_TYPE.py 2015-09-29 17:10:42.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/constants/FIELD_TYPE.py 2016-07-26 05:09:33.000000000 +0200 @@ -17,6 +17,7 @@ NEWDATE = 14 VARCHAR = 15 BIT = 16 +JSON = 245 NEWDECIMAL = 246 ENUM = 247 SET = 248 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/converters.py new/PyMySQL-0.7.6/pymysql/converters.py --- old/PyMySQL-0.7.4/pymysql/converters.py 2016-05-26 06:05:45.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/converters.py 2016-07-28 17:42:45.000000000 +0200 @@ -2,6 +2,7 @@ import datetime from decimal import Decimal +import re import time from .constants import FIELD_TYPE, FLAG @@ -145,6 +146,16 @@ def escape_struct_time(obj, mapping=None): return escape_datetime(datetime.datetime(*obj[:6])) +def _convert_second_fraction(s): + if not s: + return 0 + # Pad zeros to ensure the fraction length in microseconds + s = s.ljust(6, '0') + return int(s[:6]) + +DATETIME_RE = re.compile(r"(\d{1,4})-(\d{1,2})-(\d{1,2})[T ](\d{1,2}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?") + + def convert_datetime(obj): """Returns a DATETIME or TIMESTAMP column value as a datetime object: @@ -163,23 +174,20 @@ """ if not PY2 and isinstance(obj, (bytes, bytearray)): obj = obj.decode('ascii') - if ' ' in obj: - sep = ' ' - elif 'T' in obj: - sep = 'T' - else: + + m = DATETIME_RE.match(obj) + if not m: return convert_date(obj) try: - ymd, hms = obj.split(sep, 1) - usecs = '0' - if '.' in hms: - hms, usecs = hms.split('.') - usecs = float('0.' + usecs) * 1e6 - return datetime.datetime(*[ int(x) for x in ymd.split('-')+hms.split(':')+[usecs] ]) + groups = list(m.groups()) + groups[-1] = _convert_second_fraction(groups[-1]) + return datetime.datetime(*[ int(x) for x in groups ]) except ValueError: return convert_date(obj) +TIMEDELTA_RE = re.compile(r"(-)?(\d{1,3}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?") + def convert_timedelta(obj): """Returns a TIME column as a timedelta object: @@ -200,16 +208,17 @@ """ if not PY2 and isinstance(obj, (bytes, bytearray)): obj = obj.decode('ascii') + + m = TIMEDELTA_RE.match(obj) + if not m: + return None + try: - microseconds = 0 - if "." in obj: - (obj, tail) = obj.split('.') - microseconds = float('0.' + tail) * 1e6 - hours, minutes, seconds = obj.split(':') - negate = 1 - if hours.startswith("-"): - hours = hours[1:] - negate = -1 + groups = list(m.groups()) + groups[-1] = _convert_second_fraction(groups[-1]) + negate = -1 if groups[0] else 1 + hours, minutes, seconds, microseconds = groups[1:] + tdelta = datetime.timedelta( hours = int(hours), minutes = int(minutes), @@ -220,6 +229,9 @@ except ValueError: return None +TIME_RE = re.compile(r"(\d{1,2}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?") + + def convert_time(obj): """Returns a TIME column as a time object: @@ -244,17 +256,21 @@ """ if not PY2 and isinstance(obj, (bytes, bytearray)): obj = obj.decode('ascii') + + m = TIME_RE.match(obj) + if not m: + return None + try: - microseconds = 0 - if "." in obj: - (obj, tail) = obj.split('.') - microseconds = float('0.' + tail) * 1e6 - hours, minutes, seconds = obj.split(':') + groups = list(m.groups()) + groups[-1] = _convert_second_fraction(groups[-1]) + hours, minutes, seconds, microseconds = groups return datetime.time(hour=int(hours), minute=int(minutes), second=int(seconds), microsecond=int(microseconds)) except ValueError: return None + def convert_date(obj): """Returns a DATE column as a date object: @@ -324,7 +340,7 @@ #def convert_bit(b): # b = "\x00" * (8 - len(b)) + b # pad w/ zeroes # return struct.unpack(">Q", b)[0] -# +# # the snippet above is right, but MySQLdb doesn't process bits, # so we shouldn't either convert_bit = through diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/cursors.py new/PyMySQL-0.7.6/pymysql/cursors.py --- old/PyMySQL-0.7.4/pymysql/cursors.py 2016-05-26 06:05:45.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/cursors.py 2016-07-28 17:42:45.000000000 +0200 @@ -30,6 +30,8 @@ #: Default value of max_allowed_packet is 1048576. max_stmt_length = 1024000 + _defer_warnings = False + def __init__(self, connection): ''' Do not create an instance of a Cursor yourself. Call @@ -43,6 +45,7 @@ self._executed = None self._result = None self._rows = None + self._warnings_handled = False def close(self): ''' @@ -86,6 +89,9 @@ """Get the next query set""" conn = self._get_db() current_result = self._result + # for unbuffered queries warnings are only available once whole result has been read + if unbuffered: + self._show_warnings() if current_result is None or current_result is not conn._result: return None if not current_result.has_next: @@ -144,7 +150,7 @@ :param str query: Query to execute. - :param args: arameters used with query. (optional) + :param args: parameters used with query. (optional) :type args: tuple, list or dict :return: Number of affected rows @@ -328,14 +334,18 @@ self.description = result.description self.lastrowid = result.insert_id self._rows = result.rows + self._warnings_handled = False - if result.warning_count > 0: - self._show_warnings(conn) + if not self._defer_warnings: + self._show_warnings() - def _show_warnings(self, conn): - if self._result and self._result.has_next: + def _show_warnings(self): + if self._warnings_handled: + return + self._warnings_handled = True + if self._result and (self._result.has_next or not self._result.warning_count): return - ws = conn.show_warnings() + ws = self._get_db().show_warnings() if ws is None: return for w in ws: @@ -343,7 +353,7 @@ if PY2: if isinstance(msg, unicode): msg = msg.encode('utf-8', 'replace') - warnings.warn(str(msg), err.Warning, 4) + warnings.warn(err.Warning(*w[1:3]), stacklevel=4) def __iter__(self): return iter(self.fetchone, None) @@ -404,6 +414,8 @@ possible to scroll backwards, as only the current row is held in memory. """ + _defer_warnings = True + def _conv_row(self, row): return row @@ -440,6 +452,7 @@ self._check_executed() row = self.read_next() if row is None: + self._show_warnings() return None self.rownumber += 1 return row @@ -473,6 +486,7 @@ for i in range_type(size): row = self.read_next() if row is None: + self._show_warnings() break rows.append(row) self.rownumber += 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/tests/test_DictCursor.py new/PyMySQL-0.7.6/pymysql/tests/test_DictCursor.py --- old/PyMySQL-0.7.4/pymysql/tests/test_DictCursor.py 2015-09-29 17:10:42.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/tests/test_DictCursor.py 2016-07-28 17:42:45.000000000 +0200 @@ -21,7 +21,9 @@ with warnings.catch_warnings(): warnings.filterwarnings("ignore") c.execute("drop table if exists dictcursor") - c.execute("""CREATE TABLE dictcursor (name char(20), age int , DOB datetime)""") + # include in filterwarnings since for unbuffered dict cursor warning for lack of table + # will only be propagated at start of next execute() call + c.execute("""CREATE TABLE dictcursor (name char(20), age int , DOB datetime)""") data = [("bob", 21, "1990-02-06 23:04:56"), ("jim", 56, "1955-05-09 13:12:45"), ("fred", 100, "1911-09-12 01:01:01")] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/tests/test_basic.py new/PyMySQL-0.7.6/pymysql/tests/test_basic.py --- old/PyMySQL-0.7.4/pymysql/tests/test_basic.py 2016-05-26 06:05:45.000000000 +0200 +++ new/PyMySQL-0.7.6/pymysql/tests/test_basic.py 2016-07-28 17:42:45.000000000 +0200 @@ -1,15 +1,16 @@ -import pymysql.cursors - -from pymysql.tests import base -from pymysql import util -from pymysql.err import ProgrammingError - -import time +# coding: utf-8 import datetime +import json +import time import warnings from unittest2 import SkipTest +from pymysql import util +import pymysql.cursors +from pymysql.tests import base +from pymysql.err import ProgrammingError + __all__ = ["TestConversion", "TestCursor", "TestBulkInserts"] @@ -238,6 +239,31 @@ self.assertEqual([(1,)], list(c.fetchall())) c.close() + def test_json(self): + args = self.databases[0].copy() + args["charset"] = "utf8mb4" + conn = pymysql.connect(**args) + if not self.mysql_server_is(conn, (5, 7, 0)): + raise SkipTest("JSON type is not supported on MySQL <= 5.6") + + self.safe_create_table(conn, "test_json", """\ +create table test_json ( + id int not null, + json JSON not null, + primary key (id) +);""") + cur = conn.cursor() + + json_str = u'{"hello": "こんにちは"}' + cur.execute("INSERT INTO test_json (id, `json`) values (42, %s)", (json_str,)) + cur.execute("SELECT `json` from `test_json` WHERE `id`=42") + res = cur.fetchone()[0] + self.assertEqual(json.loads(res), json.loads(json_str)) + + cur.execute("SELECT CAST(%s AS JSON) AS x", (json_str,)) + res = cur.fetchone()[0] + self.assertEqual(json.loads(res), json.loads(json_str)) + class TestBulkInserts(base.PyMySQLTestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/tests/test_converters.py new/PyMySQL-0.7.6/pymysql/tests/test_converters.py --- old/PyMySQL-0.7.4/pymysql/tests/test_converters.py 2016-01-14 03:51:30.000000000 +0100 +++ new/PyMySQL-0.7.6/pymysql/tests/test_converters.py 2016-07-26 05:09:26.000000000 +0200 @@ -1,3 +1,4 @@ +import datetime from unittest import TestCase from pymysql._compat import PY2 @@ -21,3 +22,46 @@ converters.escape_string(b"foo\nbar"), b"foo\\nbar" ) + + def test_convert_datetime(self): + expected = datetime.datetime(2007, 2, 24, 23, 6, 20) + dt = converters.convert_datetime('2007-02-24 23:06:20') + self.assertEqual(dt, expected) + + def test_convert_datetime_with_fsp(self): + expected = datetime.datetime(2007, 2, 24, 23, 6, 20, 511581) + dt = converters.convert_datetime('2007-02-24 23:06:20.511581') + self.assertEqual(dt, expected) + + def _test_convert_timedelta(self, with_negate=False, with_fsp=False): + d = {'hours': 789, 'minutes': 12, 'seconds': 34} + s = '%(hours)s:%(minutes)s:%(seconds)s' % d + if with_fsp: + d['microseconds'] = 511581 + s += '.%(microseconds)s' % d + + expected = datetime.timedelta(**d) + if with_negate: + expected = -expected + s = '-' + s + + tdelta = converters.convert_timedelta(s) + self.assertEqual(tdelta, expected) + + def test_convert_timedelta(self): + self._test_convert_timedelta(with_negate=False, with_fsp=False) + self._test_convert_timedelta(with_negate=True, with_fsp=False) + + def test_convert_timedelta_with_fsp(self): + self._test_convert_timedelta(with_negate=False, with_fsp=True) + self._test_convert_timedelta(with_negate=False, with_fsp=True) + + def test_convert_time(self): + expected = datetime.time(23, 6, 20) + time_obj = converters.convert_time('23:06:20') + self.assertEqual(time_obj, expected) + + def test_convert_time_with_fsp(self): + expected = datetime.time(23, 6, 20, 511581) + time_obj = converters.convert_time('23:06:20.511581') + self.assertEqual(time_obj, expected) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/tests/test_issues.py new/PyMySQL-0.7.6/pymysql/tests/test_issues.py --- old/PyMySQL-0.7.4/pymysql/tests/test_issues.py 2016-01-10 06:17:46.000000000 +0100 +++ new/PyMySQL-0.7.6/pymysql/tests/test_issues.py 2016-07-28 17:42:45.000000000 +0200 @@ -4,6 +4,8 @@ import sys import pymysql +from pymysql import cursors +from pymysql._compat import text_type from pymysql.tests import base import unittest2 @@ -457,7 +459,7 @@ # select WKT query = "SELECT AsText(geom) FROM issue363" - if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)): + if self.mysql_server_is(conn, (5, 7, 0)): with self.assertWarns(pymysql.err.Warning) as cm: cur.execute(query) else: @@ -467,7 +469,7 @@ # select WKB query = "SELECT AsBinary(geom) FROM issue363" - if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)): + if self.mysql_server_is(conn, (5, 7, 0)): with self.assertWarns(pymysql.err.Warning) as cm: cur.execute(query) else: @@ -486,3 +488,28 @@ # don't assert the exact internal binary value, as it could # vary across implementations self.assertTrue(isinstance(row[0], bytes)) + + def test_issue_491(self): + """ Test warning propagation """ + conn = pymysql.connect(charset="utf8", **self.databases[0]) + + with warnings.catch_warnings(): + # Ignore all warnings other than pymysql generated ones + warnings.simplefilter("ignore") + warnings.simplefilter("error", category=pymysql.Warning) + + # verify for both buffered and unbuffered cursor types + for cursor_class in (cursors.Cursor, cursors.SSCursor): + c = conn.cursor(cursor_class) + try: + c.execute("SELECT CAST('124b' AS SIGNED)") + c.fetchall() + except pymysql.Warning as e: + # Warnings should have errorcode and string message, just like exceptions + self.assertEqual(len(e.args), 2) + self.assertEqual(e.args[0], 1292) + self.assertTrue(isinstance(e.args[1], text_type)) + else: + self.fail("Should raise Warning") + finally: + c.close() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/pymysql/tests/test_load_local.py new/PyMySQL-0.7.6/pymysql/tests/test_load_local.py --- old/PyMySQL-0.7.4/pymysql/tests/test_load_local.py 2016-01-06 03:55:53.000000000 +0100 +++ new/PyMySQL-0.7.6/pymysql/tests/test_load_local.py 2016-07-15 18:43:37.000000000 +0200 @@ -1,4 +1,4 @@ -from pymysql import OperationalError, Warning +from pymysql import cursors, OperationalError, Warning from pymysql.tests import base import os @@ -42,6 +42,28 @@ finally: c.execute("DROP TABLE test_load_local") + def test_unbuffered_load_file(self): + """Test unbuffered load local infile with a valid file""" + conn = self.connections[0] + c = conn.cursor(cursors.SSCursor) + c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") + filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), + 'data', + 'load_local_data.txt') + try: + c.execute( + ("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " + + "test_load_local FIELDS TERMINATED BY ','").format(filename) + ) + c.execute("SELECT COUNT(*) FROM test_load_local") + self.assertEqual(22749, c.fetchone()[0]) + finally: + c.close() + conn.close() + conn.connect() + c = conn.cursor() + c.execute("DROP TABLE test_load_local") + def test_load_warnings(self): """Test load local infile produces the appropriate warnings""" conn = self.connections[0] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyMySQL-0.7.4/setup.cfg new/PyMySQL-0.7.6/setup.cfg --- old/PyMySQL-0.7.4/setup.cfg 2016-05-26 06:14:55.000000000 +0200 +++ new/PyMySQL-0.7.6/setup.cfg 2016-07-29 05:27:02.000000000 +0200 @@ -1,5 +1,5 @@ -[wheel] -universal = 1 +[bdist_wheel] +universal = False [flake8] ignore = E226,E301,E701
participants (1)
-
root@hilbert.suse.de