From 809179bae93182db9cc3fffcdb96ebdb4f117489 Mon Sep 17 00:00:00 2001 From: JWM Date: Mon, 5 Aug 2024 10:00:32 +0200 Subject: [PATCH] Fix flake8 --- mlx/coverity_services.py | 9 +++------ tests/test_coverity.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/mlx/coverity_services.py b/mlx/coverity_services.py index 788d2707..55518113 100644 --- a/mlx/coverity_services.py +++ b/mlx/coverity_services.py @@ -4,7 +4,6 @@ # General import csv -import json import logging import re from sphinx.util.logging import getLogger @@ -12,8 +11,6 @@ # For Coverity - REST API import requests -from mlx.coverity_logging import report_info - # Coverity built in Impact statuses IMPACT_LIST = {"High", "Medium", "Low"} @@ -166,13 +163,13 @@ def _request(self, url, data=None): if data: response = self.session.post(url, json=data) else: - response= self.session.get(url) + response = self.session.get(url) if response.ok: return response.json() try: - err_msg= response.json()["message"] + err_msg = response.json()["message"] except (requests.exceptions.JSONDecodeError, KeyError): - err_msg= response.content.decode() + err_msg = response.content.decode() logger = getLogger("coverity_logging") logger.warning(err_msg) return response.raise_for_status() diff --git a/tests/test_coverity.py b/tests/test_coverity.py index 685e8383..f2364440 100644 --- a/tests/test_coverity.py +++ b/tests/test_coverity.py @@ -63,8 +63,8 @@ def test_get_defects(self): }, "checkerAttributedata": [ { - "key": "checker_key", - "value": "checker_value" + "key": "checker_key", + "value": "checker_value" } ] } @@ -85,10 +85,10 @@ def test_get_defects(self): with requests_mock.mock() as mocker: with open("tests/column_keys.json", "r") as content: column_keys = json.loads(content.read()) - mocker.get(column_keys_url, json = column_keys) - mocker.get(checkers_url, json = fake_checkers) - mocker.get(stream_url, json = {"stream": "valid"}) - mocker.post(issues_url, json = fake_json) + mocker.get(column_keys_url, json=column_keys) + mocker.get(checkers_url, json=fake_checkers) + mocker.get(stream_url, json={"stream": "valid"}) + mocker.post(issues_url, json=fake_json) # Validate stream name coverity_conf_service.validate_stream(fake_stream) @@ -120,11 +120,11 @@ def test_failed_login(self): stream_url = f"{coverity_conf_service.base_url.rstrip('/')}/streams/{fake_stream}" with requests_mock.mock() as mocker: - mocker.get(stream_url, headers={"Authorization": "Basic fail"}, status_code = 401) + mocker.get(stream_url, headers={"Authorization": "Basic fail"}, status_code=401) # Login to Coverity coverity_conf_service.login("user", "password") # Validate stream name with self.assertRaises(requests.HTTPError) as err: coverity_conf_service.validate_stream(fake_stream) - self.assertEqual(err.exception.response.status_code,401) + self.assertEqual(err.exception.response.status_code, 401)