1212from pymysqlreplication .row_event import *
1313from pymysqlreplication .packet import BinLogPacketWrapper
1414from pymysql .protocol import MysqlPacket
15+ from unittest .mock import patch
1516import pytest
1617
1718
@@ -1133,7 +1134,8 @@ def test_rand_event(self):
11331134 self .assertEqual (type (expected_rand_event .seed1 ), int )
11341135 self .assertEqual (type (expected_rand_event .seed2 ), int )
11351136
1136- def test_user_var_string_event (self ):
1137+ @patch ("sys.stdout" , new_callable = io .StringIO )
1138+ def test_user_var_string_event (self , mock_stdout ):
11371139 self .execute (
11381140 "CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR(50), PRIMARY KEY (id))"
11391141 )
@@ -1154,6 +1156,11 @@ def test_user_var_string_event(self):
11541156 self .assertEqual (expected_user_var_event .type , 0 )
11551157 self .assertEqual (expected_user_var_event .charset , 33 )
11561158
1159+ # Test _dump method
1160+ expected_user_var_event ._dump ()
1161+ self .assertIn ("User variable name: " , mock_stdout .getvalue ())
1162+ self .assertIn ("Value: " , mock_stdout .getvalue ())
1163+
11571164 def test_user_var_real_event (self ):
11581165 self .execute (
11591166 "CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data REAL, PRIMARY KEY (id))"
0 commit comments