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
@@ -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