diff --git a/sdks/python/apache_beam/yaml/yaml_transform_test.py b/sdks/python/apache_beam/yaml/yaml_transform_test.py index 4cfe625fc9cd..5a1e7b9e2205 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_test.py @@ -295,11 +295,10 @@ def test_csv_to_json(self): pd.testing.assert_frame_equal(data, result) def test_circular_reference_validation(self): - with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( - pickle_library='cloudpickle')) as p: - # pylint: disable=expression-not-assigned - with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): - p | YamlTransform( + with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): + with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( + pickle_library='cloudpickle')) as p: + _ = p | YamlTransform( ''' type: composite transforms: @@ -318,11 +317,10 @@ def test_circular_reference_validation(self): providers=TEST_PROVIDERS) def test_circular_reference_multi_inputs_validation(self): - with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( - pickle_library='cloudpickle')) as p: - # pylint: disable=expression-not-assigned - with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): - p | YamlTransform( + with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): + with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( + pickle_library='cloudpickle')) as p: + _ = p | YamlTransform( ''' type: composite transforms: @@ -362,11 +360,10 @@ def test_name_is_not_ambiguous(self): assert_that(result, equal_to([0, 1, 9, 16])) def test_name_is_ambiguous(self): - with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( - pickle_library='cloudpickle')) as p: - # pylint: disable=expression-not-assigned - with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): - p | YamlTransform( + with self.assertRaisesRegex(ValueError, r'Circular reference detected.*'): + with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( + pickle_library='cloudpickle')) as p: + _ = p | YamlTransform( ''' type: composite transforms: @@ -389,11 +386,11 @@ def test_name_is_ambiguous(self): providers=TEST_PROVIDERS) def test_empty_inputs_throws_error(self): - with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( - pickle_library='cloudpickle')) as p: - with self.assertRaisesRegex(ValueError, - 'Missing inputs for transform at ' - '"EmptyInputOkButYamlDoesntKnow" at line .*'): + with self.assertRaisesRegex(ValueError, + 'Missing inputs for transform at ' + '"EmptyInputOkButYamlDoesntKnow" at line .*'): + with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( + pickle_library='cloudpickle')) as p: _ = p | YamlTransform( ''' type: composite