Skip to content

Commit b62f901

Browse files
authored
Merge pull request #141 from TotallyNotRobots/gonzobot+fix-warnings
Fix warnings in tests and plugins
2 parents c8229ba + 40d0059 commit b62f901

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

cloudbot/hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def add_hook(self, regex_param, kwargs):
117117
# we only use regex.search anyways, so this is a good determiner
118118
self.regexes.append(regex_param)
119119
else:
120-
assert isinstance(regex_param, collections.Iterable)
120+
assert isinstance(regex_param, collections.abc.Iterable)
121121
# if the parameter is a list, add each one
122122
for re_to_match in regex_param:
123123
if isinstance(re_to_match, str):

plugins/core/chan_track.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import logging
1010
import time
1111
import weakref
12-
from collections import Mapping, Iterable, namedtuple
12+
from collections.abc import Mapping, Iterable
13+
from collections import namedtuple
1314
from contextlib import suppress
1415
from numbers import Number
1516
from operator import attrgetter

tests/core_tests/test_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Bot(MagicMock):
88
loop = asyncio.get_event_loop()
99

1010

11-
class TestClient(Client): # pylint: disable=abstract-method
11+
class MockClient(Client): # pylint: disable=abstract-method
1212
_connected = False
1313

1414
def __init__(self, bot, *args, **kwargs):
@@ -23,7 +23,7 @@ async def connect(self, timeout=None):
2323
self._connected = True
2424

2525

26-
class FailingTestClient(TestClient): # pylint: disable=abstract-method
26+
class FailingMockClient(MockClient): # pylint: disable=abstract-method
2727
def __init__(self, *args, fail_count=None, **kwargs):
2828
super().__init__(*args, **kwargs)
2929
self.fail_count = fail_count
@@ -35,14 +35,14 @@ async def connect(self, timeout=None):
3535

3636

3737
def test_client_no_config():
38-
client = TestClient(
38+
client = MockClient(
3939
Bot(), 'foo', 'foobot', channels=['#foo']
4040
)
4141
assert client.config.get('a') is None
4242

4343

4444
def test_client():
45-
client = TestClient(
45+
client = MockClient(
4646
Bot(), 'foo', 'foobot', channels=['#foo'], config={'name': 'foo'}
4747
)
4848

@@ -60,15 +60,15 @@ def test_client():
6060

6161
def test_client_connect_exc():
6262
with patch('random.randrange', return_value=1):
63-
client = FailingTestClient(
63+
client = FailingMockClient(
6464
Bot(), 'foo', 'foobot', channels=['#foo'], config={'name': 'foo'},
6565
fail_count=1
6666
)
6767
client.loop.run_until_complete(client.try_connect())
6868

6969

7070
def test_auto_reconnect():
71-
client = TestClient(
71+
client = MockClient(
7272
Bot(), 'foo', 'foobot', channels=['#foo'], config={'name': 'foo'}
7373
)
7474

tests/plugin_tests/test_core_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Bot(MagicMock):
1212
loop = asyncio.get_event_loop()
1313

1414

15-
class TestClient(Client): # pylint: disable=abstract-method
15+
class MockClient(Client): # pylint: disable=abstract-method
1616
def __init__(self, bot, *args, **kwargs):
1717
super().__init__(bot, 'TestClient', *args, **kwargs)
1818
self.active = True
@@ -21,7 +21,7 @@ def __init__(self, bot, *args, **kwargs):
2121

2222

2323
async def test_do_joins():
24-
client = TestClient(
24+
client = MockClient(
2525
Bot(), 'foo', 'foobot', channels=['#foo']
2626
)
2727
from plugins.core import core_misc

tests/plugin_tests/test_cryptocurrency.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from datetime import datetime, timedelta
23
from typing import Dict, List
34
from unittest.mock import MagicMock
@@ -239,7 +240,7 @@ def test_schema_unknown_fields():
239240
input_data = {'a': {'a': 'hello', 'b': 'world'}, 'c': 1}
240241
with pytest.warns(
241242
UserWarning,
242-
match=r"Unknown fields: \['c'\] while parsing schema 'NestedSchema'",
243+
match=re.escape("Unknown fields: ['c'] while parsing schema 'NestedSchema'"),
243244
):
244245
cryptocurrency.read_data(input_data, NestedSchema)
245246

0 commit comments

Comments
 (0)