Skip to content

Commit 87261f4

Browse files
committed
Merge pull request #97 from jammons/master
Fix bug in __eq__ comparison on Channel class
2 parents 8150fa9 + 814adb9 commit 87261f4

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

slackclient/_channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def __init__(self, server, name, channel_id, members=None):
66
self.members = [] if members is None else members
77

88
def __eq__(self, compare_str):
9-
if self.name == compare_str or self.name == "#" + compare_str or self.id == compare_str:
9+
if self.name == compare_str or "#" + self.name == compare_str or self.id == compare_str:
1010
return True
1111
else:
1212
return False

tests/test_channel.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
import pytest
33

44

5-
def test_Channel(channel):
5+
def test_channel(channel):
66
assert type(channel) == Channel
77

8+
def test_channel_eq(channel):
9+
channel = Channel(
10+
'test-server',
11+
'test-channel',
12+
'C12345678',
13+
)
14+
assert channel == 'test-channel'
15+
assert channel == '#test-channel'
16+
assert channel == 'C12345678'
17+
assert (channel == 'foo') is False
818

919
@pytest.mark.xfail
10-
def test_Channel_send_message(channel):
20+
def test_channel_send_message(channel):
1121
channel.send_message('hi')

0 commit comments

Comments
 (0)