Skip to content

Commit fbb5d5c

Browse files
committed
Move assert_match to the tests as is only used there
1 parent 3130f55 commit fbb5d5c

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

pygdbmi/gdbmiparser.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import functools
1111
import logging
1212
import re
13-
from pprint import pprint
1413
from typing import Callable, Dict, List, Match, Optional, Pattern, Tuple, Union
1514

1615
from pygdbmi.printcolor import fmt_green
@@ -80,19 +79,6 @@ def response_is_finished(gdb_mi_text: str) -> bool:
8079
return _GDB_MI_RESPONSE_FINISHED_RE.match(gdb_mi_text) is not None
8180

8281

83-
def assert_match(actual_char_or_str, expected_char_or_str):
84-
# Skip: If values don't match, print them and raise a ValueError, otherwise,
85-
# continue
86-
# Raises: ValueError if arguments do not match"""
87-
if expected_char_or_str != actual_char_or_str:
88-
print("Expected")
89-
pprint(expected_char_or_str)
90-
print("")
91-
print("Got")
92-
pprint(actual_char_or_str)
93-
raise ValueError()
94-
95-
9682
# ========================================================================
9783
# All functions and variables below are used internally to parse mi output
9884
# ========================================================================

tests/test_pygdbmi.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import subprocess
1313
from time import time
1414
from distutils.spawn import find_executable
15+
from pprint import pprint
1516
from pygdbmi.StringStream import StringStream
1617
from pygdbmi.gdbescapes import advance_past_string_with_gdb_escapes, unescape
17-
from pygdbmi.gdbmiparser import parse_response, assert_match
18+
from pygdbmi.gdbmiparser import parse_response
1819
from pygdbmi.gdbcontroller import GdbController
1920
from pygdbmi.constants import GdbTimeoutError, USING_WINDOWS
2021

@@ -25,6 +26,18 @@
2526
MAKE_CMD = "make"
2627

2728

29+
def assert_match(actual_char_or_str, expected_char_or_str):
30+
"""If values don't match, print them and raise a ValueError, otherwise, continue.
31+
Raises: ValueError if arguments do not match"""
32+
if expected_char_or_str != actual_char_or_str:
33+
print("Expected")
34+
pprint(expected_char_or_str)
35+
print("")
36+
print("Got")
37+
pprint(actual_char_or_str)
38+
raise ValueError()
39+
40+
2841
class TestPyGdbMi(unittest.TestCase):
2942
def test_parser(self):
3043
"""Test that the parser returns dictionaries from gdb mi strings as expected"""

0 commit comments

Comments
 (0)