From cb280323e56be262ab75f3e49f5530b024299213 Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Sat, 11 May 2019 15:58:20 +0500 Subject: [PATCH] Don't always place new variables before the modified ones --- pysnooper/tracer.py | 4 +--- tests/test_pysnooper.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index b488a11..459ae84 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -296,9 +296,7 @@ class Tracer: if name not in old_local_reprs: self.write('{indent}{newish_string}{name} = {value_repr}'.format( **locals())) - - for name, value_repr in local_reprs.items(): - if name in old_local_reprs and old_local_reprs[name] != value_repr: + elif old_local_reprs[name] != value_repr: self.write('{indent}Modified var:.. {name} = {value_repr}'.format( **locals())) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index 4e31f14..d3882e4 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -276,8 +276,8 @@ def test_watch_explode(): VariableEntry('(lst + [])[2]', '9'), VariableEntry('lst + []'), LineEntry(), - VariableEntry('(lst + [])[3]', '10'), VariableEntry('lst'), + VariableEntry('(lst + [])[3]', '10'), VariableEntry('lst + []'), ReturnEntry(), ReturnValueEntry('None')