Copilot commented on code in PR #34547: URL: https://github.com/apache/beam/pull/34547#discussion_r2029872547
########## sdks/python/apache_beam/io/textio_test.py: ########## @@ -192,6 +194,37 @@ def _run_read_test( read_data = list(source.read(range_tracker)) self.assertCountEqual(expected_data, read_data) + @unittest.skipIf(platform.system() == 'Windows', 'Skipping on Windows') + def test_read_from_text_file_pattern_with_dot_slash(self): + cwd = os.getcwd() + expected = ['abc', 'de'] + with TempDir() as temp_dir: + temp_dir.create_temp_file(suffix='.txt', lines=[b'a', b'b', b'c']) + temp_dir.create_temp_file(suffix='.txt', lines=[b'd', b'e']) + + os.chdir(temp_dir.get_path()) + with TestPipeline() as p: + dot_slash = p | 'ReadDotSlash' >> ReadFromText('./*.txt') + no_dot_slash = p | 'ReadNoSlash' >> ReadFromText('*.txt') + + assert_that(dot_slash, equal_to(expected)) + assert_that(no_dot_slash, equal_to(expected)) + os.chdir(cwd) + Review Comment: Consider using a try-finally block to ensure os.chdir(cwd) is executed even if an exception is raised during pipeline execution, so that the working directory is always restored. ```suggestion try: with TestPipeline() as p: dot_slash = p | 'ReadDotSlash' >> ReadFromText('./*.txt') no_dot_slash = p | 'ReadNoSlash' >> ReadFromText('*.txt') assert_that(dot_slash, equal_to(expected)) assert_that(no_dot_slash, equal_to(expected)) finally: os.chdir(cwd) ``` -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org