Skip to content

Commit

Permalink
Chore: F ix Minor Issue ✨ (#601)
Browse files Browse the repository at this point in the history
Summary:
- Convert for loop into list comprehension
- Use `with` when opening file to ensure closure

Pull Request resolved: #601

Reviewed By: mengxuanzhangz

Differential Revision: D49887278

Pulled By: stcheng

fbshipit-source-id: 425497bbc1a43b9df044de100fee732e81196186
  • Loading branch information
yezz123 authored and facebook-github-bot committed Oct 4, 2023
1 parent 438b9b0 commit 7511fe3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
19 changes: 10 additions & 9 deletions facebook_business/test/integration_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand All @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions facebook_business/test/other_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
python -m facebook_business.test.other_docs
'''


import os
import sys
import json
Expand All @@ -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:
Expand Down

0 comments on commit 7511fe3

Please sign in to comment.