Skip to content

Commit

Permalink
TST: enable MySQL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Mar 12, 2014
1 parent 1127d70 commit 3ac2bdf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions ci/requirements-2.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ beautifulsoup4==4.2.1
statsmodels==0.5.0
bigquery==2.0.17
sqlalchemy==0.8.1
pymysql==0.6.1
psycopg2==2.5.2
1 change: 1 addition & 0 deletions ci/requirements-3.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ scipy==0.12.0
beautifulsoup4==4.2.1
statsmodels==0.4.3
sqlalchemy==0.9.1
pymysql==0.6.1
psycopg2==2.5.2
2 changes: 1 addition & 1 deletion pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def read_table(self, table_name, index_col=None, coerce_float=True,
parse_dates=None, columns=None):

table = PandasSQLTable(table_name, self, index=index_col)
return table.read(coerce_float=parse_dates,
return table.read(coerce_float=coerce_float,
parse_dates=parse_dates, columns=columns)

def drop_table(self, table_name):
Expand Down
22 changes: 20 additions & 2 deletions pandas/io/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_read_table_absent(self):
self.assertRaises(
ValueError, sql.read_table, "this_doesnt_exist", con=self.conn)

def test_default_type_convertion(self):
def test_default_type_conversion(self):
df = sql.read_table("types_test_data", self.conn)

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

self._load_test1_data()

def test_default_type_convertion(self):
def test_default_type_conversion(self):
df = sql.read_table("types_test_data", self.conn)

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

def test_default_type_conversion(self):
df = sql.read_table("types_test_data", self.conn)

self.assertTrue(issubclass(df.FloatCol.dtype.type, np.floating),
"FloatCol loaded with incorrect type")
self.assertTrue(issubclass(df.IntCol.dtype.type, np.integer),
"IntCol loaded with incorrect type")
# MySQL has no real BOOL type (it's an alias for TINYINT)
self.assertTrue(issubclass(df.BoolCol.dtype.type, np.integer),
"BoolCol loaded with incorrect type")

# Int column with NA values stays as float
self.assertTrue(issubclass(df.IntColWithNull.dtype.type, np.floating),
"IntColWithNull loaded with incorrect type")
# Bool column with NA = int column with NA values => becomes float
self.assertTrue(issubclass(df.BoolColWithNull.dtype.type, np.floating),
"BoolColWithNull loaded with incorrect type")


class TestPostgreSQLAlchemy(_TestSQLAlchemy):
flavor = 'postgresql'
Expand Down

0 comments on commit 3ac2bdf

Please sign in to comment.