MCPcopy
hub / github.com/cool-RR/PySnooper / test_variables_classes

Function test_variables_classes

tests/test_pysnooper.py:446–494  ·  view source on GitHub ↗
(normalize)

Source from the content-addressed store, hash-verified

444
445@pytest.mark.parametrize("normalize", (True, False))
446def test_variables_classes(normalize):
447 class WithSlots(object):
448 __slots__ = ('x', 'y')
449
450 def __init__(self):
451 self.x = 3
452 self.y = 4
453
454 @pysnooper.snoop(watch=(
455 pysnooper.Keys('_d', exclude='c'),
456 pysnooper.Attrs('_d'), # doesn't have attributes
457 pysnooper.Attrs('_s'),
458 pysnooper.Indices('_lst')[-3:],
459 ), normalize=normalize, color=False)
460 def my_function():
461 _d = {'a': 1, 'b': 2, 'c': 'ignore'}
462 _s = WithSlots()
463 _lst = list(range(1000))
464
465 with mini_toolbox.OutputCapturer(stdout=False,
466 stderr=True) as output_capturer:
467 result = my_function()
468 assert result is None
469 output = output_capturer.string_io.getvalue()
470 assert_output(
471 output,
472 (
473 SourcePathEntry(),
474 VariableEntry('WithSlots'),
475 CallEntry('def my_function():'),
476 LineEntry(),
477 VariableEntry('_d'),
478 VariableEntry("_d['a']", '1'),
479 VariableEntry("_d['b']", '2'),
480 LineEntry(),
481 VariableEntry('_s'),
482 VariableEntry('_s.x', '3'),
483 VariableEntry('_s.y', '4'),
484 LineEntry(),
485 VariableEntry('_lst'),
486 VariableEntry('_lst[997]', '997'),
487 VariableEntry('_lst[998]', '998'),
488 VariableEntry('_lst[999]', '999'),
489 ReturnEntry(),
490 ReturnValueEntry('None'),
491 ElapsedTimeEntry(),
492 ),
493 normalize=normalize,
494 )
495
496
497@pytest.mark.parametrize("normalize", (True, False))

Callers

nothing calls this directly

Calls 9

my_functionFunction · 0.85
assert_outputFunction · 0.85
SourcePathEntryClass · 0.85
VariableEntryClass · 0.85
CallEntryClass · 0.85
LineEntryClass · 0.85
ReturnEntryClass · 0.85
ReturnValueEntryClass · 0.85
ElapsedTimeEntryClass · 0.85

Tested by

no test coverage detected