Skip to content

Commit 2c3eaa0

Browse files
committed
pretty printing call args, fix #7
1 parent 47a3847 commit 2c3eaa0

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

devtools/prettier.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ def _format_tuples(self, value: tuple, value_repr: str, indent_current: int, ind
103103
self._stream.write(value.__class__.__name__ + '(\n')
104104
for field, v in zip(fields, value):
105105
self._stream.write(indent_new * self._c)
106-
self._stream.write(field)
107-
self._stream.write('=')
106+
if field: # field is falsy for odd things like call_args
107+
self._stream.write(str(field))
108+
self._stream.write('=')
108109
self._format(v, indent_new, False)
109110
self._stream.write(',\n')
110111
self._stream.write(indent_current * self._c + ')')

tests/test_prettier.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import string
22
from collections import OrderedDict, namedtuple
3+
from unittest.mock import MagicMock
34

45
import numpy
56

@@ -206,3 +207,15 @@ def test_deep_objects():
206207
),
207208
{1, 2, 3},
208209
)"""
210+
211+
212+
def test_call_args():
213+
m = MagicMock()
214+
m(1, 2, 3, a=4)
215+
v = pformat(m.call_args)
216+
217+
assert v == """\
218+
_Call(
219+
(1, 2, 3),
220+
{'a': 4},
221+
)"""

0 commit comments

Comments
 (0)