Fix label-sensitive test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/2a59a121 Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/2a59a121 Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/2a59a121 Branch: refs/heads/python-sdk Commit: 2a59a121441a003bad949ae6a23d58a9cf2b3059 Parents: 2ff5630 Author: Robert Bradshaw <rober...@google.com> Authored: Fri Jul 22 16:24:48 2016 -0700 Committer: Robert Bradshaw <rober...@gmail.com> Committed: Sat Jul 23 16:43:46 2016 -0700 ---------------------------------------------------------------------- sdks/python/apache_beam/pipeline.py | 4 ++++ sdks/python/apache_beam/transforms/ptransform_test.py | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/2a59a121/sdks/python/apache_beam/pipeline.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/pipeline.py b/sdks/python/apache_beam/pipeline.py index aeed9f9..0572466 100644 --- a/sdks/python/apache_beam/pipeline.py +++ b/sdks/python/apache_beam/pipeline.py @@ -348,6 +348,10 @@ class AppliedPTransform(object): # root producer. self.refcounts = collections.defaultdict(int) + def __repr__(self): + return "%s(%s, %s)" % (self.__class__.__name__, self.full_label, + type(self.transform).__name__) + def update_input_refcounts(self): """Increment refcounts for all transforms providing inputs.""" http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/2a59a121/sdks/python/apache_beam/transforms/ptransform_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/transforms/ptransform_test.py b/sdks/python/apache_beam/transforms/ptransform_test.py index 8121c1e..3a71ec3 100644 --- a/sdks/python/apache_beam/transforms/ptransform_test.py +++ b/sdks/python/apache_beam/transforms/ptransform_test.py @@ -54,28 +54,28 @@ class PTransformTest(unittest.TestCase): pa = Pipeline('DirectPipelineRunner') res = pa | 'a_label' >> beam.Create([1, 2]) - self.assertEqual('<Create(PTransform) label=[a_label]>', - str(res.producer.transform)) + self.assertEqual('AppliedPTransform(a_label, Create)', + str(res.producer)) pc = Pipeline('DirectPipelineRunner') - res = pc | 'with_inputs' >> beam.Create([1, 2]) + res = pc | beam.Create([1, 2]) inputs_tr = res.producer.transform inputs_tr.inputs = ('ci',) self.assertEqual( - """<Create(PTransform) label=[with_inputs] inputs=('ci',)>""", + """<Create(PTransform) label=[Create] inputs=('ci',)>""", str(inputs_tr)) pd = Pipeline('DirectPipelineRunner') - res = pd | 'with_sidei' >> beam.Create([1, 2]) + res = pd | beam.Create([1, 2]) side_tr = res.producer.transform side_tr.side_inputs = (4,) self.assertEqual( - '<Create(PTransform) label=[with_sidei] side_inputs=(4,)>', + '<Create(PTransform) label=[Create] side_inputs=(4,)>', str(side_tr)) inputs_tr.side_inputs = ('cs',) self.assertEqual( - """<Create(PTransform) label=[with_inputs] """ + """<Create(PTransform) label=[Create] """ """inputs=('ci',) side_inputs=('cs',)>""", str(inputs_tr))