Skip to content

Commit a9fcc65

Browse files
committed
fix odd cases for 35 vs 36
1 parent 2c3eaa0 commit a9fcc65

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

devtools/prettier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ 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-
if field: # field is falsy for odd things like call_args
106+
if field: # field is falsy sometimes for odd things like call_args
107107
self._stream.write(str(field))
108108
self._stream.write('=')
109109
self._format(v, indent_new, False)

tests/test_prettier.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import string
2+
import sys
23
from collections import OrderedDict, namedtuple
34
from unittest.mock import MagicMock
45

56
import numpy
7+
import pytest
68

79
from devtools.ansi import strip_ansi
810
from devtools.prettier import PrettyFormat, pformat, pprint
@@ -209,7 +211,8 @@ def test_deep_objects():
209211
)"""
210212

211213

212-
def test_call_args():
214+
@pytest.mark.skipif(sys.version_info >= (3, 6), reason='like this only for 3.5')
215+
def test_call_args_py35():
213216
m = MagicMock()
214217
m(1, 2, 3, a=4)
215218
v = pformat(m.call_args)
@@ -219,3 +222,16 @@ def test_call_args():
219222
(1, 2, 3),
220223
{'a': 4},
221224
)"""
225+
226+
227+
@pytest.mark.skipif(sys.version_info < (3, 6), reason='different for 3.5')
228+
def test_call_args_py36():
229+
m = MagicMock()
230+
m(1, 2, 3, a=4)
231+
v = pformat(m.call_args)
232+
233+
assert v == """\
234+
_Call(
235+
_fields=(1, 2, 3),
236+
{'a': 4},
237+
)"""

0 commit comments

Comments
 (0)