Repository: beam Updated Branches: refs/heads/master 459a8f836 -> 074031cac
Cleanup files after the tests end Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/a732f227 Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/a732f227 Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/a732f227 Branch: refs/heads/master Commit: a732f227b2f768855bbe5ecac32bd357aeda2a55 Parents: 459a8f8 Author: Sourabh Bajaj <[email protected]> Authored: Fri Jan 27 15:46:30 2017 -0800 Committer: Ahmet Altay <[email protected]> Committed: Tue Feb 7 09:58:28 2017 -0800 ---------------------------------------------------------------------- sdks/python/apache_beam/examples/snippets/snippets_test.py | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/a732f227/sdks/python/apache_beam/examples/snippets/snippets_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/examples/snippets/snippets_test.py b/sdks/python/apache_beam/examples/snippets/snippets_test.py index 4827e94..95c959b 100644 --- a/sdks/python/apache_beam/examples/snippets/snippets_test.py +++ b/sdks/python/apache_beam/examples/snippets/snippets_test.py @@ -427,14 +427,18 @@ class SnippetsTest(unittest.TestCase): # real data. beam.io.ReadFromText = SnippetsTest.DummyReadTransform beam.io.WriteToText = SnippetsTest.DummyWriteTransform + self.temp_files = [] def tearDown(self): beam.io.ReadFromText = self.old_read_from_text beam.io.WriteToText = self.old_write_to_text + # Cleanup all the temporary files created in the test + map(os.remove, self.temp_files) def create_temp_file(self, contents=''): with tempfile.NamedTemporaryFile(delete=False) as f: f.write(contents) + self.temp_files.append(f.name) return f.name def get_output(self, path, sorted_output=True, suffix=''): @@ -560,6 +564,8 @@ class SnippetsTest(unittest.TestCase): gzip_file_name = temp_path + '.gz' with open(temp_path) as src, gzip.open(gzip_file_name, 'wb') as dst: dst.writelines(src) + # Add the temporary gzip file to be cleaned up as well. + self.temp_files.append(gzip_file_name) snippets.model_textio_compressed( {'read': gzip_file_name}, ['aa', 'bb', 'cc'])
