Formatting: Format all python code with black.
This CL is probably not what you're looking for, it's only
automated formatting. Ignore it with
`git blame --ignore-rev <revision>` for this commit.
BUG=b:233893248
TEST=CQ
Change-Id: I66591d7a738d241aed3290138c0f68065ab10a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3879174
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/api/message_util_unittest.py b/api/message_util_unittest.py
index ec7fe91..767a4a8 100644
--- a/api/message_util_unittest.py
+++ b/api/message_util_unittest.py
@@ -12,95 +12,97 @@
class JsonSerializerTest(cros_test_lib.TestCase):
- """Tests for the JSON serializer."""
+ """Tests for the JSON serializer."""
- def test_serialization(self):
- """Test json format serialization/deserialization."""
- serializer = message_util.JsonSerializer()
+ def test_serialization(self):
+ """Test json format serialization/deserialization."""
+ serializer = message_util.JsonSerializer()
- # Build a message.
- msg = build_api_test_pb2.TestRequestMessage()
- msg.id = 'foo'
+ # Build a message.
+ msg = build_api_test_pb2.TestRequestMessage()
+ msg.id = "foo"
- # Round trip the message contents through the serializer.
- serialized = serializer.serialize(msg)
- deserialized = build_api_test_pb2.TestRequestMessage()
- serializer.deserialize(serialized, deserialized)
+ # Round trip the message contents through the serializer.
+ serialized = serializer.serialize(msg)
+ deserialized = build_api_test_pb2.TestRequestMessage()
+ serializer.deserialize(serialized, deserialized)
- # Create an identical message manually.
- source = '{"id":"foo"}'
- deserialized2 = build_api_test_pb2.TestRequestMessage()
- serializer.deserialize(source, deserialized2)
+ # Create an identical message manually.
+ source = '{"id":"foo"}'
+ deserialized2 = build_api_test_pb2.TestRequestMessage()
+ serializer.deserialize(source, deserialized2)
- # Make sure the round tripped data is equal, and matches the manually
- # constructed version.
- self.assertEqual(deserialized, msg)
- self.assertEqual(deserialized, deserialized2)
+ # Make sure the round tripped data is equal, and matches the manually
+ # constructed version.
+ self.assertEqual(deserialized, msg)
+ self.assertEqual(deserialized, deserialized2)
class BinarySerializerTest(cros_test_lib.TestCase):
- """Tests for the binary serializer."""
+ """Tests for the binary serializer."""
- def test_serialization(self):
- """Test binary format serialization/deserialization."""
- serializer = message_util.BinarySerializer()
+ def test_serialization(self):
+ """Test binary format serialization/deserialization."""
+ serializer = message_util.BinarySerializer()
- # Build a message.
- msg = build_api_test_pb2.TestRequestMessage()
- msg.id = 'foo'
+ # Build a message.
+ msg = build_api_test_pb2.TestRequestMessage()
+ msg.id = "foo"
- # Round trip the message contents through the serializer.
- serialized = serializer.serialize(msg)
- deserialized = build_api_test_pb2.TestRequestMessage()
- serializer.deserialize(serialized, deserialized)
+ # Round trip the message contents through the serializer.
+ serialized = serializer.serialize(msg)
+ deserialized = build_api_test_pb2.TestRequestMessage()
+ serializer.deserialize(serialized, deserialized)
- # Make sure the round tripped data is unchanged.
- self.assertEqual(msg, deserialized)
+ # Make sure the round tripped data is unchanged.
+ self.assertEqual(msg, deserialized)
class MessageHandlerTest(cros_test_lib.TempDirTestCase):
- """MessageHandler tests."""
+ """MessageHandler tests."""
- def test_binary_serialization(self):
- """Test binary serialization/deserialization."""
- msg_path = os.path.join(self.tempdir, 'proto')
+ def test_binary_serialization(self):
+ """Test binary serialization/deserialization."""
+ msg_path = os.path.join(self.tempdir, "proto")
- # Use the message handler configured in the module to avoid config drift.
- handler = message_util.get_message_handler(msg_path,
- message_util.FORMAT_BINARY)
+ # Use the message handler configured in the module to avoid config drift.
+ handler = message_util.get_message_handler(
+ msg_path, message_util.FORMAT_BINARY
+ )
- msg = build_api_test_pb2.TestRequestMessage()
- msg.id = 'foo'
+ msg = build_api_test_pb2.TestRequestMessage()
+ msg.id = "foo"
- # Round trip the data.
- self.assertNotExists(msg_path)
- handler.write_from(msg)
- self.assertExists(msg_path)
+ # Round trip the data.
+ self.assertNotExists(msg_path)
+ handler.write_from(msg)
+ self.assertExists(msg_path)
- deserialized = build_api_test_pb2.TestRequestMessage()
- handler.read_into(deserialized)
+ deserialized = build_api_test_pb2.TestRequestMessage()
+ handler.read_into(deserialized)
- # Make sure the data has not mutated.
- self.assertEqual(msg, deserialized)
+ # Make sure the data has not mutated.
+ self.assertEqual(msg, deserialized)
- def test_json_serialization(self):
- """Test json serialization/deserialization."""
- msg_path = os.path.join(self.tempdir, 'proto')
+ def test_json_serialization(self):
+ """Test json serialization/deserialization."""
+ msg_path = os.path.join(self.tempdir, "proto")
- # Use the message handler configured in the module to avoid config drift.
- handler = message_util.get_message_handler(msg_path,
- message_util.FORMAT_JSON)
+ # Use the message handler configured in the module to avoid config drift.
+ handler = message_util.get_message_handler(
+ msg_path, message_util.FORMAT_JSON
+ )
- msg = build_api_test_pb2.TestRequestMessage()
- msg.id = 'foo'
+ msg = build_api_test_pb2.TestRequestMessage()
+ msg.id = "foo"
- # Round trip the data.
- self.assertNotExists(msg_path)
- handler.write_from(msg)
- self.assertExists(msg_path)
+ # Round trip the data.
+ self.assertNotExists(msg_path)
+ handler.write_from(msg)
+ self.assertExists(msg_path)
- deserialized = build_api_test_pb2.TestRequestMessage()
- handler.read_into(deserialized)
+ deserialized = build_api_test_pb2.TestRequestMessage()
+ handler.read_into(deserialized)
- # Make sure the data has not mutated.
- self.assertEqual(msg, deserialized)
+ # Make sure the data has not mutated.
+ self.assertEqual(msg, deserialized)