ibzib commented on a change in pull request #13812:
URL: https://github.com/apache/beam/pull/13812#discussion_r564931019



##########
File path: sdks/python/apache_beam/coders/coders_test_common.py
##########
@@ -63,6 +65,34 @@ class CodersTest(unittest.TestCase):
   # These class methods ensure that we test each defined coder in both
   # nested and unnested context.
 
+  # Common test values representing Python's built-in types.
+  values_deterministic: List[Any] = [

Review comment:
       Nit: `values_deterministic` is kind of vague, `values` even more so. Can 
we rename to `test_values*`?

##########
File path: sdks/python/apache_beam/coders/coders_test_common.py
##########
@@ -63,6 +65,34 @@ class CodersTest(unittest.TestCase):
   # These class methods ensure that we test each defined coder in both
   # nested and unnested context.
 
+  # Common test values representing Python's built-in types.

Review comment:
       👍 

##########
File path: sdks/python/apache_beam/coders/coder_impl.py
##########
@@ -336,18 +336,18 @@ def __init__(self, proto_message_type):
     self.proto_message_type = proto_message_type
 
   def encode(self, value):
-    return value.SerializeToString()
+    return value.SerializePartialToString()
 
   def decode(self, encoded):
     proto_message = self.proto_message_type()
-    proto_message.ParseFromString(encoded)
+    proto_message.ParseFromString(encoded)  # This is in effect "ParsePartial".

Review comment:
       `# This is in effect "ParsePartial".` -> Why is this the case?

##########
File path: sdks/python/apache_beam/coders/coders_test_common.py
##########
@@ -129,12 +159,20 @@ def test_custom_coder(self):
         (-10, b'b'), (5, b'c'))
 
   def test_pickle_coder(self):
-    self.check_coder(coders.PickleCoder(), 'a', 1, 1.5, (1, 2, 3))
+    coder = coders.PickleCoder()
+    self.check_coder(coder, *self.values)
 
   def test_deterministic_coder(self):
     coder = coders.FastPrimitivesCoder()
     deterministic_coder = coders.DeterministicFastPrimitivesCoder(coder, 
'step')
-    self.check_coder(deterministic_coder, 'a', 1, 1.5, (1, 2, 3))
+    self.check_coder(deterministic_coder, *self.values_deterministic)
+    for v in self.values_deterministic:
+      self.check_coder(coders.TupleCoder((deterministic_coder, )), (v, ))

Review comment:
       What makes TupleCoder a special case here? What coverage does this check 
provide that `self.check_coder(deterministic_coder, (1, 2, 3))` didn't?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to