Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff UP015 (6) #34955

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def load_json_from_file(path):
with open(path, 'r') as _json_file:
with open(path) as _json_file:
return json.load(_json_file)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ def delete_snapshot(self, **kwargs):
def ack_messages(self, a, b):
return ""

with open("test_data/commands_outputs.json", "r") as f:
with open("test_data/commands_outputs.json") as f:
COMMAND_OUTPUTS = json.load(f)
with open("test_data/raw_responses.json", "r") as f:
with open("test_data/raw_responses.json") as f:
RAW_RESPONSES = json.load(f)

TEST_COMMANDS_LIST = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_make_markdown_matrix():
- return a Markdown table with the headers of the sheets and the data inside them
'''
path = 'test_data/helper_functions/test_make_markdown_matrix/'
with open(path + 'result.md', 'r') as file:
with open(path + 'result.md') as file:
result = file.read()
assert GoogleSheets.make_markdown_matrix(util_load_json(os.path.join(path, 'sheets.json'))) == result

Expand Down Expand Up @@ -92,7 +92,7 @@ def test_prepare_result_with_echo(mocker):
{'SheetId': 0, 'Sheet title': "Sheet1"}])
response = util_load_json('test_data/helper_functions/test_prepare_result_echo/response.json')
command_result = GoogleSheets.prepare_result(response, {"echo_spreadsheet": "true"}, "")
with open('test_data/helper_functions/test_prepare_result_echo/markdown_result.md', 'r') as file:
with open('test_data/helper_functions/test_prepare_result_echo/markdown_result.md') as file:
markdown_assert = file.read()
assert command_result.readable_output == markdown_assert
assert command_result.outputs == response
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_markdown_single_get(mocker):
mocker.patch.object(GoogleSheets, 'create_list_id_title', return_value=[{'SheetId': 0, 'Sheet title': 'Sheet1'}])
response = util_load_json(os.path.join(path, 'get_response.json'))
markdown = GoogleSheets.markdown_single_get(response)
with open(os.path.join(path, 'markdown_assert.md'), 'r') as file:
with open(os.path.join(path, 'markdown_assert.md')) as file:
markdown_assert = file.read()
assert markdown == markdown_assert

Expand Down Expand Up @@ -260,7 +260,7 @@ def test_create_spreadsheet():
service = build('sheets', 'v4', http=http, developerKey=api_key)
args = util_load_json(path + 'args.json')
command_result = GoogleSheets.create_spreadsheet(service, args)
with open(os.path.join(path, 'command_results_readable_output.md'), 'r') as file:
with open(os.path.join(path, 'command_results_readable_output.md')) as file:
markdown_assert = file.read()
assert command_result.readable_output == markdown_assert
assert command_result.outputs == util_load_json(os.path.join(path, 'command_results_outputs.json'))
Expand All @@ -287,7 +287,7 @@ def test_get_single_spreadsheet(path):
api_key = 'your_api_key'
service = build('sheets', 'v4', http=http, developerKey=api_key)
command_result = GoogleSheets.get_spreadsheet(service, util_load_json(os.path.join(path, 'args.json')))
with open(path + 'markdown.md', 'r') as file:
with open(path + 'markdown.md') as file:
markdown_assert = file.read()
assert command_result.readable_output == markdown_assert
assert command_result.outputs == util_load_json(os.path.join(path, 'output.json'))
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_get_multiple_spreadsheets():
http=http,
developerKey=api_key)
command_result = GoogleSheets.get_spreadsheet(service, args)
with open(os.path.join(path, 'markdown.md'), 'r') as file:
with open(os.path.join(path, 'markdown.md')) as file:
markdown_assert = file.read()
assert command_result.readable_output == markdown_assert
assert command_result.outputs is None
Expand Down Expand Up @@ -369,6 +369,6 @@ def test_sheet_create_both_ways(path):
args = util_load_json(os.path.join(path, 'args.json'))
command_result = GoogleSheets.create_sheet(service, args)
assert command_result.outputs == util_load_json(os.path.join(path, 'command_result_output.json'))
with open(os.path.join(path, 'readable_output.md'), 'r') as file:
with open(os.path.join(path, 'readable_output.md')) as file:
markdown_assert = file.read()
assert command_result.readable_output == markdown_assert
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def load_json_file(file_description):
file_path = TEST_PATH / f"{file_description}.json"
with open(file_path, "r") as f:
with open(file_path) as f:
return f.read()


Expand Down
6 changes: 3 additions & 3 deletions Packs/Kafka/Integrations/KafkaV3/KafkaV3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,11 @@ def test_ssl_configuration():
}
assert kafka.conf_consumer == expected_consumer_conf
assert kafka.conf_producer == expected_producer_conf
with open(kafka.ca_path, 'r') as f:
with open(kafka.ca_path) as f:
assert f.read() == 'ca_cert'
with open(kafka.client_cert_path, 'r') as f:
with open(kafka.client_cert_path) as f:
assert f.read() == 'client_cert'
with open(kafka.client_key_path, 'r') as f:
with open(kafka.client_key_path) as f:
assert f.read() == 'client_cert_key'
os.remove(kafka.ca_path)
os.remove(kafka.client_cert_path)
Expand Down
Loading