Title: [276970] trunk/Tools
Revision
276970
Author
aakash_j...@apple.com
Date
2021-05-04 11:14:48 -0700 (Tue, 04 May 2021)

Log Message

[ews] Ensure file handles are not leaked in unit tests
https://bugs.webkit.org/show_bug.cgi?id=225360

Reviewed by Jonathan Bedard.

* CISupport/ews-build/email_unittest.py:
(EmailsDotJSONTest.test_valid_emails_json):
(EmailsDotJSONTest.test_emails_json_required_categories_present):
* CISupport/ews-build/loadConfig_unittest.py:
(ConfigDotJSONTest.get_config):

Modified Paths

Diff

Modified: trunk/Tools/CISupport/ews-build/email_unittest.py (276969 => 276970)


--- trunk/Tools/CISupport/ews-build/email_unittest.py	2021-05-04 18:04:16 UTC (rev 276969)
+++ trunk/Tools/CISupport/ews-build/email_unittest.py	2021-05-04 18:14:48 UTC (rev 276970)
@@ -31,14 +31,16 @@
 class EmailsDotJSONTest(unittest.TestCase):
     def test_valid_emails_json(self):
         cwd = os.path.dirname(os.path.abspath(__file__))
-        json.load(open(os.path.join(cwd, 'emails.json')))
+        with open(os.path.join(cwd, 'emails.json')) as emails_json:
+            json.load(emails_json)
 
     def test_emails_json_required_categories_present(self):
         cwd = os.path.dirname(os.path.abspath(__file__))
-        emails = json.load(open(os.path.join(cwd, 'emails.json')))
-        valid_email_categories = ['ADMIN_EMAILS', 'APPLE_BOT_WATCHERS_EMAILS', 'EMAIL_IDS_TO_UNSUBSCRIBE', 'IGALIA_JSC_TEAM_EMAILS', 'IGALIA_GTK_WPE_EMAILS']
-        for category in valid_email_categories:
-            self.assertTrue(category in list(emails.keys()))
+        with open(os.path.join(cwd, 'emails.json')) as emails_json:
+            emails = json.load(emails_json)
+            valid_email_categories = ['ADMIN_EMAILS', 'APPLE_BOT_WATCHERS_EMAILS', 'EMAIL_IDS_TO_UNSUBSCRIBE', 'IGALIA_JSC_TEAM_EMAILS', 'IGALIA_GTK_WPE_EMAILS']
+            for category in valid_email_categories:
+                self.assertTrue(category in list(emails.keys()))
 
 
 if __name__ == '__main__':

Modified: trunk/Tools/CISupport/ews-build/loadConfig_unittest.py (276969 => 276970)


--- trunk/Tools/CISupport/ews-build/loadConfig_unittest.py	2021-05-04 18:04:16 UTC (rev 276969)
+++ trunk/Tools/CISupport/ews-build/loadConfig_unittest.py	2021-05-04 18:14:48 UTC (rev 276970)
@@ -33,7 +33,8 @@
 class ConfigDotJSONTest(unittest.TestCase):
     def get_config(self):
         cwd = os.path.dirname(os.path.abspath(__file__))
-        return json.load(open(os.path.join(cwd, 'config.json')))
+        with open(os.path.join(cwd, 'config.json'), 'r') as config:
+            return json.load(config)
 
     def get_builder_from_config(self, config, builder_name):
         for builder in config['builders']:

Modified: trunk/Tools/ChangeLog (276969 => 276970)


--- trunk/Tools/ChangeLog	2021-05-04 18:04:16 UTC (rev 276969)
+++ trunk/Tools/ChangeLog	2021-05-04 18:14:48 UTC (rev 276970)
@@ -1,3 +1,16 @@
+2021-05-04  Aakash Jain  <aakash_j...@apple.com>
+
+        [ews] Ensure file handles are not leaked in unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=225360
+
+        Reviewed by Jonathan Bedard.
+
+        * CISupport/ews-build/email_unittest.py:
+        (EmailsDotJSONTest.test_valid_emails_json):
+        (EmailsDotJSONTest.test_emails_json_required_categories_present):
+        * CISupport/ews-build/loadConfig_unittest.py:
+        (ConfigDotJSONTest.get_config):
+
 2021-05-04  Kate Cheney  <katherine_che...@apple.com>
 
         Unreviewed, adding myself as a reviewer.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to