Skip to content

Commit 9b5f2b2

Browse files
committed
TST: Refactor sql test inheritance
Pytest wouldn't discover the tests in the same way as nose when 1. The base class inherits from `TestCase`, and 2. The base class doesn't start with `Test` (e.g. PandasSQLTest) 3. The parent class with test methods doesn't start with `Test` ( e.g. _TestSQLAPI) We solved this by moving the class inheriting from `TestCase` down a level from `PandasSQLTest` to the many `TestSQL*` methods.
1 parent 3d6fcdc commit 9b5f2b2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

pandas/io/tests/test_sql.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _close_conn(self):
236236
pass
237237

238238

239-
class PandasSQLTest(unittest.TestCase):
239+
class PandasSQLTest(object):
240240
"""
241241
Base class with common private methods for SQLAlchemy and fallback cases.
242242
@@ -839,7 +839,7 @@ def test_unicode_column_name(self):
839839
df.to_sql('test_unicode', self.conn, index=False)
840840

841841

842-
class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi):
842+
class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi, unittest.TestCase):
843843
"""
844844
Test the public API as it would be used directly
845845
@@ -1024,11 +1024,11 @@ def tearDown(self):
10241024
super(_EngineToConnMixin, self).tearDown()
10251025

10261026

1027-
class TestSQLApiConn(_EngineToConnMixin, TestSQLApi):
1027+
class TestSQLApiConn(_EngineToConnMixin, TestSQLApi, unittest.TestCase):
10281028
pass
10291029

10301030

1031-
class TestSQLiteFallbackApi(SQLiteMixIn, _TestSQLApi):
1031+
class TestSQLiteFallbackApi(SQLiteMixIn, _TestSQLApi, unittest.TestCase):
10321032
"""
10331033
Test the public sqlite connection fallback API
10341034
@@ -1875,34 +1875,39 @@ def test_schema_support(self):
18751875
tm.assert_frame_equal(res1, res2)
18761876

18771877

1878-
class TestMySQLAlchemy(_TestMySQLAlchemy, _TestSQLAlchemy):
1878+
class TestMySQLAlchemy(_TestMySQLAlchemy, _TestSQLAlchemy, unittest.TestCase):
18791879
pass
18801880

18811881

1882-
class TestMySQLAlchemyConn(_TestMySQLAlchemy, _TestSQLAlchemyConn):
1882+
class TestMySQLAlchemyConn(_TestMySQLAlchemy, _TestSQLAlchemyConn,
1883+
unittest.TestCase):
18831884
pass
18841885

18851886

1886-
class TestPostgreSQLAlchemy(_TestPostgreSQLAlchemy, _TestSQLAlchemy):
1887+
class TestPostgreSQLAlchemy(_TestPostgreSQLAlchemy, _TestSQLAlchemy,
1888+
unittest.TestCase):
18871889
pass
18881890

18891891

1890-
class TestPostgreSQLAlchemyConn(_TestPostgreSQLAlchemy, _TestSQLAlchemyConn):
1892+
class TestPostgreSQLAlchemyConn(_TestPostgreSQLAlchemy, _TestSQLAlchemyConn,
1893+
unittest.TestCase):
18911894
pass
18921895

18931896

1894-
class TestSQLiteAlchemy(_TestSQLiteAlchemy, _TestSQLAlchemy):
1897+
class TestSQLiteAlchemy(_TestSQLiteAlchemy, _TestSQLAlchemy,
1898+
unittest.TestCase):
18951899
pass
18961900

18971901

1898-
class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn):
1902+
class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn,
1903+
unittest.TestCase):
18991904
pass
19001905

19011906

19021907
# -----------------------------------------------------------------------------
19031908
# -- Test Sqlite / MySQL fallback
19041909

1905-
class TestSQLiteFallback(SQLiteMixIn, PandasSQLTest):
1910+
class TestSQLiteFallback(SQLiteMixIn, PandasSQLTest, unittest.TestCase):
19061911
"""
19071912
Test the fallback mode against an in-memory sqlite database.
19081913

0 commit comments

Comments
 (0)