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

Function test_overwrite

tests/test_pysnooper.py:933–975  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

931
932
933def test_overwrite():
934 with mini_toolbox.create_temp_folder(prefix='pysnooper') as folder:
935 path = folder / 'foo.log'
936 with path.open('w') as output_file:
937 output_file.write(u'lala')
938 @pysnooper.snoop(str(path), overwrite=True, color=False)
939 def my_function(foo):
940 x = 7
941 y = 8
942 return y + x
943 result = my_function('baba')
944 result = my_function('baba')
945 assert result == 15
946 with path.open() as output_file:
947 output = output_file.read()
948 assert 'lala' not in output
949 assert_output(
950 output,
951 (
952 SourcePathEntry(),
953 VariableEntry('foo', value_regex="u?'baba'"),
954 CallEntry('def my_function(foo):'),
955 LineEntry('x = 7'),
956 VariableEntry('x', '7'),
957 LineEntry('y = 8'),
958 VariableEntry('y', '8'),
959 LineEntry('return y + x'),
960 ReturnEntry('return y + x'),
961 ReturnValueEntry('15'),
962 ElapsedTimeEntry(),
963
964 VariableEntry('foo', value_regex="u?'baba'"),
965 CallEntry('def my_function(foo):'),
966 LineEntry('x = 7'),
967 VariableEntry('x', '7'),
968 LineEntry('y = 8'),
969 VariableEntry('y', '8'),
970 LineEntry('return y + x'),
971 ReturnEntry('return y + x'),
972 ReturnValueEntry('15'),
973 ElapsedTimeEntry(),
974 )
975 )
976
977
978def test_error_in_overwrite_argument():

Callers

nothing calls this directly

Calls 11

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
openMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected