Skip to content

Commit 037e0d3

Browse files
committed
Fix SteamID regex syntax warnings
1 parent 26166e0 commit 037e0d3

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

steam/steamid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def from_csgo_friend_code(code, universe=EUniverse.Public):
501501
:return: SteamID instance
502502
:rtype: :class:`.SteamID` or :class:`None`
503503
"""
504-
if not re.match(r'^['+_csgofrcode_chars+'\-]{10}$', code):
504+
if not re.match(r'^['+_csgofrcode_chars+r'\-]{10}$', code):
505505
return None
506506

507507
code = ('AAAA-' + code).replace('-', '')
@@ -574,7 +574,7 @@ def steam64_from_url(url, http_timeout=30):
574574
# group profiles
575575
else:
576576
text = web.get(match.group('clean_url'), timeout=http_timeout).text
577-
data_match = re.search("OpenGroupChat\( *'(?P<steamid>\d+)'", text)
577+
data_match = re.search(r"OpenGroupChat\( *'(?P<steamid>\d+)'", text)
578578

579579
if data_match:
580580
return int(data_match.group('steamid'))

tests/test_steamid.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,16 @@ def test_steam64_from_url_timeout(self, mrs_mock):
337337
mm.get.side_effect = requests.exceptions.ReadTimeout('test')
338338
self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me"))
339339

340+
@mock.patch('steam.steamid.make_requests_session')
341+
def test_steam64_from_url_group_chat_markup(self, mrs_mock):
342+
mm = mrs_mock.return_value = mock.MagicMock()
343+
mm.get.return_value.text = "OpenGroupChat( '103582791429521412'"
344+
345+
self.assertEqual(
346+
steamid.steam64_from_url("https://steamcommunity.com/groups/Valve"),
347+
103582791429521412
348+
)
349+
340350
def test_steam64_from_url(self):
341351
def scrub_req(r):
342352
r.headers.pop('Cookie', None)

0 commit comments

Comments
 (0)