Some of the imports are missing. ``` # try importing import unittest import apache_beam as beam
# rest of the code. ``` try running with pytest as *pytest test.py *and it should work. Thanks, Anand On Fri, Feb 10, 2023 at 10:09 AM Julian Ogando via dev <dev@beam.apache.org> wrote: > 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 > >