robertwb commented on code in PR #30771:
URL: https://github.com/apache/beam/pull/30771#discussion_r1554092314


##########
sdks/python/apache_beam/testing/util.py:
##########
@@ -261,6 +261,22 @@ def assert_that(
   """
   assert isinstance(actual, pvalue.PCollection), (
       '%s is not a supported type for Beam assert' % type(actual))
+  pipeline = actual.pipeline
+  if getattr(actual.pipeline, 'result', None):
+    # The pipeline was already run. The user most likely called assert_that
+    # after the pipeleline context.
+    raise RuntimeError(
+        'assert_that must be used within a beam.Pipeline context')
+
+  # Usually, the uniqueness of the label is left to the pipeline
+  # writer to guarantee. Since we're in a testing context, we'll
+  # just automatically append a number to the label if it's
+  # already in use.

Review Comment:
   ```suggestion
     # already in use, as tests don't typically have to worry about long-term
     # update compatibility stability of stage names.
   ```



-- 
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.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to