Skip to content

Commit c9b55a3

Browse files
authored
Merge pull request #34177 Add test ensuring pipeline options observes kwargs.
2 parents c7edbb3 + 0c9561d commit c9b55a3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sdks/python/apache_beam/options/pipeline_options_test.py

+11
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,17 @@ def _add_argparse_args(cls, parser):
308308
self.assertEqual(result['test_arg_int'], 5)
309309
self.assertEqual(result['test_arg_none'], None)
310310

311+
def test_from_kwargs(self):
312+
class MyOptions(PipelineOptions):
313+
@classmethod
314+
def _add_argparse_args(cls, parser):
315+
parser.add_argument('--test_arg')
316+
317+
# kwarg takes precedence over parsed flag
318+
options = PipelineOptions(flags=['--test_arg=A'], test_arg='B')
319+
self.assertEqual(options.view_as(MyOptions).test_arg, 'B')
320+
self.assertEqual(options.get_all_options()['test_arg'], 'B')
321+
311322
def test_option_with_space(self):
312323
options = PipelineOptions(flags=['--option with space= value with space'])
313324
self.assertEqual(

0 commit comments

Comments
 (0)