Make predictable order of items if we don't know the proper order.

Also fix tests
This commit is contained in:
Alexander Bersenev 2019-05-11 04:24:26 +05:00 committed by Ram Rachum
parent f4117c1565
commit 92ff55d2f1
2 changed files with 7 additions and 4 deletions

View File

@ -26,8 +26,11 @@ def get_local_reprs(frame, watch=()):
for key in frame.f_code.co_varnames if key in frame.f_locals
)
result.update(sorted((key, utils.get_shortish_repr(frame.f_locals[key]))
for key in set(frame.f_locals) - set(frame.f_code.co_varnames)))
for variable in watch:
result.update(variable.items(frame))
result.update(sorted(variable.items(frame)))
return result

View File

@ -270,10 +270,10 @@ def test_watch_explode():
VariableEntry('_point.x', '3'),
VariableEntry('_point.y', '4'),
LineEntry(),
VariableEntry('lst'),
VariableEntry('(lst + [])[0]', '7'),
VariableEntry('(lst + [])[1]', '8'),
VariableEntry('(lst + [])[2]', '9'),
VariableEntry('lst'),
VariableEntry('lst + []'),
LineEntry(),
VariableEntry('(lst + [])[3]', '10'),
@ -790,23 +790,23 @@ def test_with_block():
output,
(
# In first with
VariableEntry('x', '2'),
VariableEntry('bar1'),
VariableEntry('bar2'),
VariableEntry('bar3'),
VariableEntry('foo'),
VariableEntry('qux'),
VariableEntry('snoop'),
VariableEntry('x', '2'),
LineEntry('foo(x - 1)'),
# In with in recursive call
VariableEntry('x', '1'),
VariableEntry('bar1'),
VariableEntry('bar2'),
VariableEntry('bar3'),
VariableEntry('foo'),
VariableEntry('qux'),
VariableEntry('snoop'),
VariableEntry('x', '1'),
LineEntry('foo(x - 1)'),
# Call to bar1 from if block outside with