Skip to content

Commit 09a7caa

Browse files
Refactor test method in TestMariadbBinlogStreamReader class
1 parent f357fe6 commit 09a7caa

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

pymysqlreplication/tests/base.py

+29
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,32 @@ def bin_log_basename(self):
121121
bin_log_basename = cursor.fetchone()[0]
122122
bin_log_basename = bin_log_basename.split("/")[-1]
123123
return bin_log_basename
124+
125+
126+
class PyMySQLReplicationMariaDbTestCase(PyMySQLReplicationTestCase):
127+
def setUp(self):
128+
# default
129+
self.database = {
130+
"host": "localhost",
131+
"user": "root",
132+
"passwd": "",
133+
"port": 3308,
134+
"use_unicode": True,
135+
"charset": "utf8",
136+
"db": "pymysqlreplication_test"
137+
}
138+
139+
self.conn_control = None
140+
db = copy.copy(self.database)
141+
db["db"] = None
142+
self.connect_conn_control(db)
143+
self.execute("DROP DATABASE IF EXISTS pymysqlreplication_test")
144+
self.execute("CREATE DATABASE pymysqlreplication_test")
145+
db = copy.copy(self.database)
146+
self.connect_conn_control(db)
147+
self.stream = None
148+
self.resetBinLog()
149+
150+
151+
152+

pymysqlreplication/tests/test_basic.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1002,19 +1002,7 @@ def test_parsing(self):
10021002
gtid = Gtid("57b70f4e-20d3-11e5-a393-4a63946f7eac:1-:1")
10031003
gtid = Gtid("57b70f4e-20d3-11e5-a393-4a63946f7eac::1")
10041004

1005-
class TestMariadbBinlogStreaReader(base.PyMySQLReplicationTestCase):
1006-
def setUp(self):
1007-
super(TestMariadbBinlogStreaReader,self).setUp()
1008-
self.stream.close()
1009-
maria_db = copy.copy(self.database)
1010-
maria_db["db"] = None
1011-
maria_db["port"] = 3308
1012-
self.connect_conn_control(maria_db)
1013-
self.execute("DROP DATABASE IF EXISTS pymysqlreplication_test")
1014-
self.execute("CREATE DATABASE pymysqlreplication_test")
1015-
self.isMariaDB()
1016-
self.stream = BinLogStreamReader(maria_db, server_id=1024,
1017-
ignored_events=self.ignoredEvents())
1005+
class TestMariadbBinlogStreaReader(base.PyMySQLReplicationMariaDbTestCase):
10181006

10191007
def test_gtid_list_event(self):
10201008
event = self.stream.fetchone()

0 commit comments

Comments
 (0)