Skip to content

Commit 47c7fa8

Browse files
authored
Merge pull request #587 from JeongJiHwan/test/test-user-var-string-event
test: test dump method in test_user_var_string_event
2 parents 78f9bf3 + b85f880 commit 47c7fa8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pymysqlreplication/tests/test_basic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pymysqlreplication.row_event import *
1313
from pymysqlreplication.packet import BinLogPacketWrapper
1414
from pymysql.protocol import MysqlPacket
15+
from unittest.mock import patch
1516
import pytest
1617

1718

@@ -1159,7 +1160,8 @@ def test_rand_event(self):
11591160
self.assertEqual(type(expected_rand_event.seed1), int)
11601161
self.assertEqual(type(expected_rand_event.seed2), int)
11611162

1162-
def test_user_var_string_event(self):
1163+
@patch("sys.stdout", new_callable=io.StringIO)
1164+
def test_user_var_string_event(self, mock_stdout):
11631165
self.execute(
11641166
"CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR(50), PRIMARY KEY (id))"
11651167
)
@@ -1180,6 +1182,11 @@ def test_user_var_string_event(self):
11801182
self.assertEqual(expected_user_var_event.type, 0)
11811183
self.assertEqual(expected_user_var_event.charset, 33)
11821184

1185+
# Test _dump method
1186+
expected_user_var_event._dump()
1187+
self.assertIn("User variable name: ", mock_stdout.getvalue())
1188+
self.assertIn("Value: ", mock_stdout.getvalue())
1189+
11831190
def test_user_var_real_event(self):
11841191
self.execute(
11851192
"CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data REAL, PRIMARY KEY (id))"

0 commit comments

Comments
 (0)