avoid argument collision in call of start_action in eliotutil

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
This commit is contained in:
fenn-cs 2021-09-28 09:56:14 +01:00
parent 424047ba43
commit 759d4c85a2
3 changed files with 5 additions and 4 deletions

View File

@ -312,7 +312,7 @@ class LogCallDeferredTests(TestCase):
return base ** exp
self.assertThat(f(exp=2,base=10), succeeded(Equals(100)))
msg = logger.messages[0]
assertContainsFields(self, msg, {"base": 10, "exp": 2})
assertContainsFields(self, msg, {"kwargs": {"base": 10, "exp": 2}})
@capture_logging(
@ -328,4 +328,5 @@ class LogCallDeferredTests(TestCase):
return base ** exp
self.assertThat(f(10, 2, message="an exponential function"), succeeded(Equals(100)))
msg = logger.messages[0]
assertContainsFields(self, msg, {"args": (10, 2), "message": "an exponential function"})
assertContainsFields(self, msg, {"args": (10, 2)})
assertContainsFields(self, msg, {"kwargs": {"message": "an exponential function"}})

View File

@ -121,7 +121,7 @@ class TestStreamingLogs(AsyncTestCase):
self.assertThat(len(messages), Equals(3))
self.assertThat(messages[0]["action_type"], Equals("test:cli:some-exciting-action"))
self.assertThat(messages[0]["arguments"],
self.assertThat(messages[0]["kwargs"]["arguments"],
Equals(["hello", "good-\\xff-day", 123, {"a": 35}, [None]]))
self.assertThat(messages[1]["action_type"], Equals("test:cli:some-exciting-action"))
self.assertThat("started", Equals(messages[0]["action_status"]))

View File

@ -325,7 +325,7 @@ def log_call_deferred(action_type):
# Use the action's context method to avoid ending the action when
# the `with` block ends.
kwargs = {k: bytes_to_unicode(True, kw[k]) for k in kw}
with start_action(action_type=action_type, args=a, **kwargs).context():
with start_action(action_type=action_type, args=a, kwargs=kwargs).context():
# Use addActionFinish so that the action finishes when the
# Deferred fires.
d = maybeDeferred(f, *a, **kw)