Hi,
I'm reading the documentation found in
https://beam.apache.org/documentation/pipelines/test-your-pipeline/

from apache_beam.testing.test_pipeline import TestPipelinefrom
apache_beam.testing.util import assert_thatfrom
apache_beam.testing.util import equal_to
class CountTest(unittest.TestCase):

  def test_count(self):
    # Our static input data, which will make up the initial PCollection.
    WORDS = [
      "hi", "there", "hi", "hi", "sue", "bob",
      "hi", "sue", "", "", "ZOW", "bob", ""
    ]
    # Create a test pipeline.
    with TestPipeline() as p:

      # Create an input PCollection.
      input = p | beam.Create(WORDS)

      # Apply the Count transform under test.
      output = input | beam.combiners.Count.PerElement()

      # Assert on the results.
      assert_that(
        output,
        equal_to([
            ("hi", 4),
            ("there", 1),
            ("sue", 2),
            ("bob", 2),
            ("", 3),
            ("ZOW", 1)]))


It's a little bit unclear how to run the unit test. If execute it with
"python3 test.py --runner DirectRunner" I get an error message:
class CountTest(unittest.TestCase):
NameError: name 'unittest' is not defined

Thanks!
-- 

Julian Ogando

Cloud Data Engineer

Latam Eng Delivery Center

+54 911 65715933

julianoga...@google.com

Reply via email to