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

Function test_watch

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

Source from the content-addressed store, hash-verified

337
338@pytest.mark.parametrize("normalize", (True, False))
339def test_watch(normalize):
340 class Foo(object):
341 def __init__(self):
342 self.x = 2
343
344 def square(self):
345 self.x **= 2
346
347 @pysnooper.snoop(watch=(
348 'foo.x',
349 'io.__name__',
350 'len(foo.__dict__["x"] * "abc")',
351 ), normalize=normalize, color=False)
352 def my_function():
353 foo = Foo()
354 for i in range(2):
355 foo.square()
356
357 with mini_toolbox.OutputCapturer(stdout=False,
358 stderr=True) as output_capturer:
359 result = my_function()
360 assert result is None
361 output = output_capturer.string_io.getvalue()
362 assert_output(
363 output,
364 (
365 SourcePathEntry(),
366 VariableEntry('Foo'),
367 VariableEntry('io.__name__', "'io'"),
368 CallEntry('def my_function():'),
369 LineEntry('foo = Foo()'),
370 VariableEntry('foo'),
371 VariableEntry('foo.x', '2'),
372 VariableEntry('len(foo.__dict__["x"] * "abc")', '6'),
373 LineEntry(),
374 VariableEntry('i', '0'),
375 LineEntry(),
376 VariableEntry('foo.x', '4'),
377 VariableEntry('len(foo.__dict__["x"] * "abc")', '12'),
378 LineEntry(),
379 VariableEntry('i', '1'),
380 LineEntry(),
381 VariableEntry('foo.x', '16'),
382 VariableEntry('len(foo.__dict__["x"] * "abc")', '48'),
383 LineEntry(),
384 ReturnEntry(),
385 ReturnValueEntry('None'),
386 ElapsedTimeEntry(),
387 ),
388 normalize=normalize,
389 )
390
391
392@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