mirror of https://github.com/mahmoud/boltons.git
add tests and determinism to format_invocation
This commit is contained in:
parent
626df0f696
commit
f4188bd9d1
|
@ -296,7 +296,7 @@ def format_invocation(name='', args=(), kwargs=None):
|
|||
kwargs = kwargs or {}
|
||||
a_text = ', '.join([repr(a) for a in args])
|
||||
if isinstance(kwargs, dict):
|
||||
kwarg_items = kwargs.items()
|
||||
kwarg_items = [(k, kwargs[k]) for k in sorted(kwargs)]
|
||||
else:
|
||||
kwarg_items = kwargs
|
||||
kw_text = ', '.join(['%s=%r' % (k, v) for k, v in kwarg_items])
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from boltons.funcutils import (copy_function,
|
||||
total_ordering,
|
||||
format_invocation,
|
||||
InstancePartial,
|
||||
CachedInstancePartial)
|
||||
|
||||
|
@ -61,3 +62,10 @@ def test_total_ordering():
|
|||
assert num < 5
|
||||
assert num >= 2
|
||||
assert num != 1
|
||||
|
||||
|
||||
def test_format_invocation():
|
||||
assert format_invocation('d') == "d()"
|
||||
assert format_invocation('f', ('a', 'b')) == "f('a', 'b')"
|
||||
assert format_invocation('g', (), {'x': 'y'}) == "g(x='y')"
|
||||
assert format_invocation('h', ('a', 'b'), {'x': 'y', 'z': 'zz'}) == "h('a', 'b', x='y', z='zz')"
|
||||
|
|
Loading…
Reference in New Issue