From 7511fe3f753bcec6e9c6bdb89fff14b045b00491 Mon Sep 17 00:00:00 2001 From: Yasser Tahiri Date: Tue, 3 Oct 2023 19:35:47 -0700 Subject: [PATCH] =?UTF-8?q?Chore:=20F=20ix=20Minor=20Issue=20=E2=9C=A8=20(?= =?UTF-8?q?#601)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: - Convert for loop into list comprehension - Use `with` when opening file to ensure closure Pull Request resolved: https://github.com/facebook/facebook-python-business-sdk/pull/601 Reviewed By: mengxuanzhangz Differential Revision: D49887278 Pulled By: stcheng fbshipit-source-id: 425497bbc1a43b9df044de100fee732e81196186 --- .../test/integration_test_runner.py | 19 ++++++++++--------- facebook_business/test/other_docs.py | 7 +++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/facebook_business/test/integration_test_runner.py b/facebook_business/test/integration_test_runner.py index acad734cd..1681c3cd9 100755 --- a/facebook_business/test/integration_test_runner.py +++ b/facebook_business/test/integration_test_runner.py @@ -28,6 +28,7 @@ How to run: python -m facebook_business.test.integration_test_runner ''' + import os, subprocess DIRECTORY = os.path.dirname(os.path.abspath(__file__)) @@ -40,15 +41,15 @@ RUNNER = "runner" CONSTANT = "constant" -integration_tests = [] -for filename in os.listdir(DIRECTORY): - if filename.endswith(".py") \ - and filename.startswith("integration_") \ - and UTILS not in filename \ - and RUNNER not in filename \ - and CONSTANT not in filename: - integration_tests.append(filename.split(".")[0]) - +integration_tests = [ + filename.split(".")[0] + for filename in os.listdir(DIRECTORY) + if filename.endswith(".py") + and filename.startswith("integration_") + and UTILS not in filename + and RUNNER not in filename + and CONSTANT not in filename +] failed = False for test in integration_tests: diff --git a/facebook_business/test/other_docs.py b/facebook_business/test/other_docs.py index 86f50a4b0..caddb7afe 100644 --- a/facebook_business/test/other_docs.py +++ b/facebook_business/test/other_docs.py @@ -25,6 +25,7 @@ python -m facebook_business.test.other_docs ''' + import os import sys import json @@ -43,10 +44,8 @@ class InsightsDocsTestCase(DocsTestCase): pass if __name__ == '__main__': - handle = open(DocsDataStore.get('filename'), 'w') - handle.write('') - handle.close() - + with open(DocsDataStore.get('filename'), 'w') as handle: + handle.write('') try: config_file = open('./config.json') except IOError: