8000 Remove auto show warnings by methane · Pull Request #774 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

Remove auto show warnings #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove tests for auto show warnings
  • Loading branch information
methane committed Jan 17, 2019
commit 66a6c4da817a28a5536015b190d071239972fd45
12 changes: 0 additions & 12 deletions pymysql/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
import json
import time
import warnings

import pytest

Expand Down Expand Up @@ -378,14 +377,3 @@ def test_issue_288(self):
age = values(age)"""))
cursor.execute('commit')
self._verify_records(data)

def test_warnings(self):
con = self.connect()
cur = con.cursor()
with warnings.catch_warnings(record=True) as ws:
warnings.simplefilter("always")
cur.execute("drop table if exists no_exists_table")
self.assertEqual(len(ws), 1)
self.assertEqual(ws[0].category, pymysql.Warning)
if u"no_exists_table" not in str(ws[0].message):
self.fail("'no_exists_table' not in %s" % (str(ws[0].message),))
25 changes: 0 additions & 25 deletions pymysql/tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,28 +485,3 @@ def test_issue_363(self):
# 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()
24 changes: 0 additions & 24 deletions pymysql/tests/test_load_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pymysql.tests import base

import os
import warnings

__all__ = ["TestLoadLocal"]

Expand Down Expand Up @@ -64,29 +63,6 @@ def test_unbuffered_load_file(self):
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.connect()
c = conn.cursor()
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_warn_data.txt')
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
c.execute(
("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " +
"test_load_local FIELDS TERMINATED BY ','").format(filename)
)
self.assertEqual(w[0].category, Warning)
expected_message = "Incorrect integer value"
if expected_message not in str(w[-1].message):
self.fail("%r not in %r" % (expected_message, w[-1].message))
finally:
c.execute("DROP TABLE test_load_local")
c.close()


if __name__ == "__main__":
import unittest
Expand Down
0