From 759d4c85a295cfd620aacbc55225ee1d8aa236b2 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Tue, 28 Sep 2021 09:56:14 +0100 Subject: [PATCH] avoid argument collision in call of start_action in eliotutil Signed-off-by: fenn-cs --- src/allmydata/test/test_eliotutil.py | 5 +++-- src/allmydata/test/web/test_logs.py | 2 +- src/allmydata/util/eliotutil.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/allmydata/test/test_eliotutil.py b/src/allmydata/test/test_eliotutil.py index 7edd4e780..1fbb9ec8d 100644 --- a/src/allmydata/test/test_eliotutil.py +++ b/src/allmydata/test/test_eliotutil.py @@ -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"}}) diff --git a/src/allmydata/test/web/test_logs.py b/src/allmydata/test/web/test_logs.py index 043541690..fe0a0445d 100644 --- a/src/allmydata/test/web/test_logs.py +++ b/src/allmydata/test/web/test_logs.py @@ -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"])) diff --git a/src/allmydata/util/eliotutil.py b/src/allmydata/util/eliotutil.py index ac2d3e4e0..e0c2fd8ae 100644 --- a/src/allmydata/util/eliotutil.py +++ b/src/allmydata/util/eliotutil.py @@ -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)