Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test dump method in test_user_var_string_event #587

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pymysqlreplication/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pymysqlreplication.row_event import *
from pymysqlreplication.packet import BinLogPacketWrapper
from pymysql.protocol import MysqlPacket
from unittest.mock import patch
import pytest


Expand Down Expand Up @@ -1133,7 +1134,8 @@ def test_rand_event(self):
self.assertEqual(type(expected_rand_event.seed1), int)
self.assertEqual(type(expected_rand_event.seed2), int)

def test_user_var_string_event(self):
@patch("sys.stdout", new_callable=io.StringIO)
def test_user_var_string_event(self, mock_stdout):
self.execute(
"CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR(50), PRIMARY KEY (id))"
)
Expand All @@ -1154,6 +1156,11 @@ def test_user_var_string_event(self):
self.assertEqual(expected_user_var_event.type, 0)
self.assertEqual(expected_user_var_event.charset, 33)

# Test _dump method
expected_user_var_event._dump()
self.assertIn("User variable name: ", mock_stdout.getvalue())
self.assertIn("Value: ", mock_stdout.getvalue())

def test_user_var_real_event(self):
self.execute(
"CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data REAL, PRIMARY KEY (id))"
Expand Down