First implementation of Debugger for SyaNodeParser
This commit is contained in:
@@ -449,3 +449,51 @@ key2: value2
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == """{'\x1b[32mkey1\x1b[0m': 'value1', 'key2': 1, 'key3': DummyObj(prop_1=3.15, prop_2='a string'), 'key4': ['alpha', 0]}
|
||||
"""
|
||||
|
||||
def test_i_can_print_out_dict_sub_items(self, capsys):
|
||||
sheerka, context, service, *rules = self.init_service_with_rules(
|
||||
("isinstance(__obj, dict)", "dict(__obj)"),
|
||||
("__key=='key1'", "green(__key)")
|
||||
)
|
||||
obj = {
|
||||
"key1": "value1",
|
||||
"key2": 1,
|
||||
"key3": DummyObj(prop_1=3.15, prop_2='a string'),
|
||||
"key4": {"a": 1, "b": "value"},
|
||||
"key5": ["alpha", 0]
|
||||
}
|
||||
service.process_return_values(context, obj)
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == """\x1b[32mkey1\x1b[0m: value1
|
||||
key2: 1
|
||||
key3: DummyObj(prop_1=3.15, prop_2='a string')
|
||||
key4: {'a': 1, 'b': 'value'}
|
||||
key5: ['alpha', 0]
|
||||
"""
|
||||
|
||||
def test_i_can_print_out_dict_with_expanded_sub_items(self, capsys):
|
||||
sheerka, context, service, *rules = self.init_service_with_rules(
|
||||
("isinstance(__obj, dict)", "dict(__obj)"),
|
||||
("__key=='key1'", "green(__key)")
|
||||
)
|
||||
obj = {
|
||||
"key1": "value1",
|
||||
"key2": 1,
|
||||
"key3": DummyObj(prop_1=3.15, prop_2='a string'),
|
||||
"key4": {"a": 1, "b": "value"},
|
||||
"key5": ["alpha", 0]
|
||||
}
|
||||
|
||||
old_value = service.out_visitors[0].console_width
|
||||
service.out_visitors[0].console_width = 5
|
||||
service.process_return_values(context, obj)
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == """\x1b[32mkey1\x1b[0m: value1
|
||||
key2: 1
|
||||
key3: DummyObj(prop_1=3.15, prop_2='a string')
|
||||
key4: {'a': 1,
|
||||
'b': 'value'}
|
||||
key5: ['alpha',
|
||||
0]
|
||||
"""
|
||||
service.out_visitors[0].console_width = old_value
|
||||
|
||||
Reference in New Issue
Block a user