Skip to content

Commit 3ac2bdf

Browse files
TST: enable MySQL tests
1 parent 1127d70 commit 3ac2bdf

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

ci/requirements-2.7.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ beautifulsoup4==4.2.1
1818
statsmodels==0.5.0
1919
bigquery==2.0.17
2020
sqlalchemy==0.8.1
21+
pymysql==0.6.1
2122
psycopg2==2.5.2

ci/requirements-3.3.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ scipy==0.12.0
1616
beautifulsoup4==4.2.1
1717
statsmodels==0.4.3
1818
sqlalchemy==0.9.1
19+
pymysql==0.6.1
1920
psycopg2==2.5.2

pandas/io/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def read_table(self, table_name, index_col=None, coerce_float=True,
668668
parse_dates=None, columns=None):
669669

670670
table = PandasSQLTable(table_name, self, index=index_col)
671-
return table.read(coerce_float=parse_dates,
671+
return table.read(coerce_float=coerce_float,
672672
parse_dates=parse_dates, columns=columns)
673673

674674
def drop_table(self, table_name):

pandas/io/tests/test_sql.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def test_read_table_absent(self):
495495
self.assertRaises(
496496
ValueError, sql.read_table, "this_doesnt_exist", con=self.conn)
497497

498-
def test_default_type_convertion(self):
498+
def test_default_type_conversion(self):
499499
df = sql.read_table("types_test_data", self.conn)
500500

501501
self.assertTrue(issubclass(df.FloatCol.dtype.type, np.floating),
@@ -589,7 +589,7 @@ def setUp(self):
589589

590590
self._load_test1_data()
591591

592-
def test_default_type_convertion(self):
592+
def test_default_type_conversion(self):
593593
df = sql.read_table("types_test_data", self.conn)
594594

595595
self.assertTrue(issubclass(df.FloatCol.dtype.type, np.floating),
@@ -755,6 +755,24 @@ def tearDown(self):
755755
for table in c.fetchall():
756756
self.conn.execute('DROP TABLE %s' % table[0])
757757

758+
def test_default_type_conversion(self):
759+
df = sql.read_table("types_test_data", self.conn)
760+
761+
self.assertTrue(issubclass(df.FloatCol.dtype.type, np.floating),
762+
"FloatCol loaded with incorrect type")
763+
self.assertTrue(issubclass(df.IntCol.dtype.type, np.integer),
764+
"IntCol loaded with incorrect type")
765+
# MySQL has no real BOOL type (it's an alias for TINYINT)
766+
self.assertTrue(issubclass(df.BoolCol.dtype.type, np.integer),
767+
"BoolCol loaded with incorrect type")
768+
769+
# Int column with NA values stays as float
770+
self.assertTrue(issubclass(df.IntColWithNull.dtype.type, np.floating),
771+
"IntColWithNull loaded with incorrect type")
772+
# Bool column with NA = int column with NA values => becomes float
773+
self.assertTrue(issubclass(df.BoolColWithNull.dtype.type, np.floating),
774+
"BoolColWithNull loaded with incorrect type")
775+
758776

759777
class TestPostgreSQLAlchemy(_TestSQLAlchemy):
760778
flavor = 'postgresql'

0 commit comments

Comments
 (0)