From e67b8bab6634a4bbf3f0c632921f43fdee7a178c Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 18 Jan 2022 17:08:52 -0800 Subject: [PATCH] Disable logging for memoization test. Test loggers may cache logged items, extending their lifetime thus violating this test's expectations about when things will be gc'd. --- sdks/python/apache_beam/dataframe/convert_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/dataframe/convert_test.py b/sdks/python/apache_beam/dataframe/convert_test.py index 78aeeffb3f4f..152c0f00d18b 100644 --- a/sdks/python/apache_beam/dataframe/convert_test.py +++ b/sdks/python/apache_beam/dataframe/convert_test.py @@ -165,6 +165,11 @@ def test_convert_memoization_clears_cache(self): # cache size gc.disable() + # Also disable logging, as some implementations may artificially extend + # the life of objects. + import logging + logging.disable(logging.INFO) + try: self.test_convert_memoization() self.assertEqual(len(convert.TO_PCOLLECTION_CACHE), 3) @@ -175,8 +180,9 @@ def test_convert_memoization_clears_cache(self): # scope and are GC'd self.assertEqual(len(convert.TO_PCOLLECTION_CACHE), 0) finally: - # Always re-enable GC + # Always re-enable GC and logging gc.enable() + logging.disable(logging.NOTSET) if __name__ == '__main__':