X7ROOT File Manager
Current Path:
/lib/python2.7/site-packages/pymysql/tests
lib
/
python2.7
/
site-packages
/
pymysql
/
tests
/
📁
..
📄
__init__.py
(600 B)
📄
__init__.pyc
(773 B)
📄
__init__.pyo
(773 B)
📄
base.py
(2.64 KB)
📄
base.pyc
(3.64 KB)
📄
base.pyo
(3.64 KB)
📄
test_DictCursor.py
(4.51 KB)
📄
test_DictCursor.pyc
(5.21 KB)
📄
test_DictCursor.pyo
(5.21 KB)
📄
test_SSCursor.py
(3.83 KB)
📄
test_SSCursor.pyc
(3.29 KB)
📄
test_SSCursor.pyo
(3.29 KB)
📄
test_basic.py
(14.54 KB)
📄
test_basic.pyc
(14.09 KB)
📄
test_basic.pyo
(14.09 KB)
📄
test_connection.py
(23.71 KB)
📄
test_connection.pyc
(24.2 KB)
📄
test_connection.pyo
(24.16 KB)
📄
test_converters.py
(2.14 KB)
📄
test_converters.pyc
(3.51 KB)
📄
test_converters.pyo
(3.51 KB)
📄
test_cursor.py
(4.09 KB)
📄
test_cursor.pyc
(4.25 KB)
📄
test_cursor.pyo
(4.21 KB)
📄
test_err.py
(670 B)
📄
test_err.pyc
(1.29 KB)
📄
test_err.pyo
(1.29 KB)
📄
test_issues.py
(19.8 KB)
📄
test_issues.pyc
(19.88 KB)
📄
test_issues.pyo
(19.82 KB)
📄
test_load_local.py
(3.5 KB)
📄
test_load_local.pyc
(3.93 KB)
📄
test_load_local.pyo
(3.93 KB)
📄
test_nextset.py
(1.81 KB)
📄
test_nextset.pyc
(2.88 KB)
📄
test_nextset.pyo
(2.88 KB)
📄
test_optionfile.py
(737 B)
📄
test_optionfile.pyc
(1.25 KB)
📄
test_optionfile.pyo
(1.25 KB)
📁
thirdparty
Editing: test_load_local.py
from pymysql import cursors, OperationalError, Warning from pymysql.tests import base import os import warnings __all__ = ["TestLoadLocal"] class TestLoadLocal(base.PyMySQLTestCase): def test_no_file(self): """Test load local infile when the file does not exist""" conn = self.connections[0] c = conn.cursor() c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") try: self.assertRaises( OperationalError, c.execute, ("LOAD DATA LOCAL INFILE 'no_data.txt' INTO TABLE " "test_load_local fields terminated by ','") ) finally: c.execute("DROP TABLE test_load_local") c.close() def test_load_file(self): """Test load local infile with a valid file""" conn = self.connections[0] 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_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.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] 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 unittest.main()
Upload File
Create Folder