Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 154f2de

Browse files
committed
Allow to run tests in parallel
Before: Ran 271 tests in 794.271s After: Ran 271 tests in 85.712s
1 parent 79670f8 commit 154f2de

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def setUpClass(cls):
1515
cls.preql = preql.Preql(TEST_MYSQL_CONN_STRING)
1616

1717
def setUp(self) -> None:
18+
self.preql = preql.Preql(TEST_MYSQL_CONN_STRING)
1819
self.preql(
1920
r"""
2021
table test_api {

tests/test_database_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,12 @@ def test_types(self, source_db, target_db, source_type, target_type, type_catego
274274
self.connections = [self.src_conn, self.dst_conn]
275275
sample_values = TYPE_SAMPLES[type_category]
276276

277-
src_table_path = src_conn.parse_table_name("src")
278-
dst_table_path = dst_conn.parse_table_name("dst")
277+
# Limit in MySQL is 64
278+
src_table_name = f"src_{self._testMethodName[:60]}"
279+
dst_table_name = f"dst_{self._testMethodName[:60]}"
280+
281+
src_table_path = src_conn.parse_table_name(src_table_name)
282+
dst_table_path = dst_conn.parse_table_name(dst_table_name)
279283
src_table = src_conn.quote(".".join(src_table_path))
280284
dst_table = dst_conn.quote(".".join(dst_table_path))
281285

tests/test_diff_tables.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,24 @@ def tearDownClass(cls):
3333
cls.connection.close()
3434

3535

36+
# Fallback for test runners that doesn't support setUpClass/tearDownClass
37+
def setUp(self) -> None:
38+
if not hasattr(self, 'connection'):
39+
self.setUpClass.__func__(self)
40+
self.private_connection = True
41+
42+
return super().setUp()
43+
44+
def tearDown(self) -> None:
45+
if hasattr(self, 'private_connection'):
46+
self.tearDownClass.__func__(self)
47+
48+
return super().tearDown()
49+
50+
3651
class TestDates(TestWithConnection):
3752
def setUp(self):
53+
super().setUp()
3854
self.connection.query("DROP TABLE IF EXISTS a", None)
3955
self.connection.query("DROP TABLE IF EXISTS b", None)
4056
self.preql(
@@ -110,6 +126,7 @@ def test_offset(self):
110126

111127
class TestDiffTables(TestWithConnection):
112128
def setUp(self):
129+
super().setUp()
113130
self.connection.query("DROP TABLE IF EXISTS ratings_test", None)
114131
self.connection.query("DROP TABLE IF EXISTS ratings_test2", None)
115132
self.preql.load("./tests/setup.pql")
@@ -221,9 +238,9 @@ def test_diff_sorted_by_key(self):
221238

222239
class TestTableSegment(TestWithConnection):
223240
def setUp(self) -> None:
241+
super().setUp()
224242
self.table = TableSegment(self.connection, ("ratings_test",), "id", "timestamp")
225243
self.table2 = TableSegment(self.connection, ("ratings_test2",), "id", "timestamp")
226-
return super().setUp()
227244

228245
def test_table_segment(self):
229246
early = datetime.datetime(2021, 1, 1, 0, 0)

0 commit comments

Comments
 (0)