You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/01/07 20:00:15 UTC

[jira] [Work logged] (BEAM-9062) Improve Beam's assert_that+equal_to error message to describe what elements cause assertion to fail

     [ https://issues.apache.org/jira/browse/BEAM-9062?focusedWorklogId=367713&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-367713 ]

ASF GitHub Bot logged work on BEAM-9062:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jan/20 19:59
            Start Date: 07/Jan/20 19:59
    Worklog Time Spent: 10m 
      Work Description: tvalentyn commented on pull request #10504: [BEAM-9062] Improve assertion error for equal_to
URL: https://github.com/apache/beam/pull/10504#discussion_r363925164
 
 

 ##########
 File path: sdks/python/apache_beam/testing/util_test.py
 ##########
 @@ -67,6 +73,26 @@ def test_assert_that_fails(self):
       with TestPipeline() as p:
         assert_that(p | Create([1, 10, 100]), equal_to([1, 2, 3]))
 
+  def test_assert_missing(self):
+    with self.assertRaisesRegex(BeamAssertException,
+                                r"missing elements \['c'\]"):
+      with TestPipeline() as p:
+        assert_that(p | Create(['a', 'b']), equal_to(['a', 'b', 'c']))
+
+  def test_assert_unexpected(self):
+    with self.assertRaisesRegex(BeamAssertException,
+                                r"unexpected elements \['c', 'd'\]"):
+      with TestPipeline() as p:
+        assert_that(p | Create(['a', 'b', 'c', 'd']), equal_to(['a', 'b']))
 
 Review comment:
   PCollections don't guarantee the order of elements, so once PCollection materializes we may access its elements in the order of 'a', 'b', 'd', 'c', in which case the generated error message will be "unexpected elements ['d', 'c']". While also correct, this message will fail current assertion. Added a small change to accommodate that, and reversed the order in try clause to avoid a warning at runtime on Py3. 
 
----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 367713)
    Remaining Estimate: 0h
            Time Spent: 10m

> Improve Beam's assert_that+equal_to error message to describe what elements cause assertion to fail 
> ----------------------------------------------------------------------------------------------------
>
>                 Key: BEAM-9062
>                 URL: https://issues.apache.org/jira/browse/BEAM-9062
>             Project: Beam
>          Issue Type: Improvement
>          Components: testing
>            Reporter: Valentyn Tymofieiev
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)