bzablocki commented on code in PR #27096:
URL: https://github.com/apache/beam/pull/27096#discussion_r1228147265
##########
sdks/python/apache_beam/yaml/readme_test.py:
##########
@@ -211,28 +215,39 @@ def parse_test_methods(markdown_lines):
test_type = 'RUN'
test_name = f'test_line_{ix + 2}'
else:
- if code_lines and code_lines[0] == 'pipeline:':
- yaml_pipeline = '\n'.join(code_lines)
- if 'providers:' in yaml_pipeline:
- test_type = 'PARSE'
- yield test_name, create_test_method(
- test_type,
- test_name,
- yaml_pipeline)
+ if code_lines:
+ if code_lines[0].startswith('- type:'):
+ # Treat this as a fragment of a larger pipeline.
+ code_lines = [
+ 'pipeline:',
+ ' type: chain',
+ ' transforms:',
+ ' - type: ReadFromCsv',
+ ' path: whatever',
+ ] + [' ' + line for line in code_lines]
+ if code_lines[0] == 'pipeline:':
+ yaml_pipeline = '\n'.join(code_lines)
+ if 'providers:' in yaml_pipeline:
+ test_type = 'PARSE'
+ yield test_name, create_test_method(
+ test_type,
+ test_name,
+ yaml_pipeline)
code_lines = None
elif code_lines is not None:
code_lines.append(line)
-def createTestSuite():
- with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
- return type(
- 'ReadMeTest', (unittest.TestCase, ), dict(parse_test_methods(readme)))
+def createTestSuite(name, path):
+ with open(path) as readme:
+ return type(name, (unittest.TestCase, ), dict(parse_test_methods(readme)))
-ReadMeTest = createTestSuite()
+ReadMeTest = createTestSuite(
+ 'ReadMeTest', os.path.join(os.path.dirname(__file__), 'README.md'))
Review Comment:
Thanks, I haven't noticed it. At some point we could refactor it so that
`readme_test.py` contains code related only to testing README.md, and then we
could create a file like `md_test_utils.py` to store functions and definitions
for testing Markdown files. But let's keep it like this for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]