From a01bfe374f13087e2a9d8c4f9b79d0678b996de4 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 13 Jun 2020 10:41:05 +0100 Subject: [PATCH] fix #271: code bugs detected by sonarcloud --- steam/client/builtins/gameservers.py | 1 + steam/core/manifest.py | 2 +- steam/webapi.py | 2 +- steam/webauth.py | 2 -- tests/test_steamid.py | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/steam/client/builtins/gameservers.py b/steam/client/builtins/gameservers.py index d6304b0..190442a 100644 --- a/steam/client/builtins/gameservers.py +++ b/steam/client/builtins/gameservers.py @@ -40,6 +40,7 @@ from steam.enums import EResult from steam.enums.emsg import EMsg from steam.utils import ip_to_int, ip_from_int from steam.utils.proto import proto_to_dict +from steam.exceptions import SteamError class GameServers(object): diff --git a/steam/core/manifest.py b/steam/core/manifest.py index 2f8bf09..7e3d213 100644 --- a/steam/core/manifest.py +++ b/steam/core/manifest.py @@ -180,7 +180,7 @@ class DepotManifest(object): try: filename = symmetric_decrypt(filename, depot_key) except Exception: - RuntimeError("Unable to decrypt filename for depot manifest") + raise RuntimeError("Unable to decrypt filename for depot manifest") mapping.filename = filename diff --git a/steam/webapi.py b/steam/webapi.py index a935fab..3fe8db9 100644 --- a/steam/webapi.py +++ b/steam/webapi.py @@ -397,7 +397,7 @@ def webapi_request(url, method='GET', caller=None, session=None, params=None): :rtype: :class:`dict`, :class:`lxml.etree.Element`, :class:`str` """ if method not in ('GET', 'POST'): - raise NotImplemented("HTTP method: %s" % repr(self.method)) + raise ValueError("Only GET and POST methods are supported, got: %s" % repr(method)) if params is None: params = {} diff --git a/steam/webauth.py b/steam/webauth.py index 3be2b57..d81ce13 100644 --- a/steam/webauth.py +++ b/steam/webauth.py @@ -230,8 +230,6 @@ class WebAuth(object): self.password = '' raise LoginIncorrect(resp['message']) - return None - def cli_login(self, password='', captcha='', email_code='', twofactor_code='', language='english'): """Generates CLI prompts to perform the entire login process diff --git a/tests/test_steamid.py b/tests/test_steamid.py index ea63993..46f06f7 100644 --- a/tests/test_steamid.py +++ b/tests/test_steamid.py @@ -185,7 +185,7 @@ class SteamID_initialization(unittest.TestCase): class SteamID_properties(unittest.TestCase): def test_repr(self): # just to cover in coverage - repr(SteamID()) + self.assertTrue('SteamID' in repr(SteamID())) def test_is_valid(self): # default