Ticket #3910: t.w.p.irc-action-2.patch
File t.w.p.irc-action-2.patch, 3.7 KB (added by , 12 years ago) |
---|
-
twisted/words/test/test_irc.py
class ClientTests(TestCase): 723 723 username, hostname, servername, self.protocol.realname), 724 724 ''] 725 725 self.assertEquals(self.transport.value().split('\r\n'), expected) 726 727 728 def test_describe(self): 729 """ 730 L{IRCClient.desrcibe} sends a CTCP ACTION message to the target 731 specified. 732 """ 733 target = 'foo' 734 channel = '#bar' 735 action = 'waves' 736 self.protocol.describe(target, action) 737 self.protocol.describe(channel, action) 738 expected = [ 739 'PRIVMSG %s :\01ACTION %s\01' % (target, action), 740 'PRIVMSG %s :\01ACTION %s\01' % (channel, action), 741 ''] 742 self.assertEquals(self.transport.value().split('\r\n'), expected) 743 744 745 def test_me(self): 746 """ 747 L{IRCClient.me} sends a CTCP ACTION message to the target channel 748 specified. 749 If the target does not begin with a standard channel prefix, 750 '#' is prepended. 751 """ 752 target = 'foo' 753 channel = '#bar' 754 action = 'waves' 755 self.protocol.me(target, action) 756 self.protocol.me(channel, action) 757 expected = [ 758 'PRIVMSG %s :\01ACTION %s\01' % ('#' + target, action), 759 'PRIVMSG %s :\01ACTION %s\01' % (channel, action), 760 ''] 761 self.assertEquals(self.transport.value().split('\r\n'), expected) 762 warnings = self.flushWarnings( 763 offendingFunctions=[self.test_me]) 764 self.assertEquals( 765 warnings[0]['message'], 766 "me() is deprecated since Twisted 9.0. Use IRCClient.describe().") 767 self.assertEquals(warnings[0]['category'], DeprecationWarning) 768 self.assertEquals(len(warnings), 2) -
twisted/words/protocols/irc.py
Test coverage needs to be better. 30 30 31 31 import errno, os, random, re, stat, struct, sys, time, types, traceback 32 32 import string, socket 33 import warnings 33 34 from os import path 34 35 35 36 from twisted.internet import reactor, protocol … … class IRCClient(basic.LineReceiver): 1067 1068 1068 1069 ### user input commands, client->client 1069 1070 1071 def describe(self, channel, action): 1072 """ 1073 Strike a pose. 1074 1075 @type channel: C{str} 1076 @param channel: The name of the channel to have an action on. If it 1077 has no prefix, it is sent to the user of that name. 1078 @type action: C{str} 1079 @param action: The action to preform. 1080 @since: 9.0 1081 """ 1082 self.ctcpMakeQuery(channel, [('ACTION', action)]) 1083 1084 1070 1085 def me(self, channel, action): 1071 1086 """ 1072 1087 Strike a pose. 1073 1088 1089 This function is deprecated since Twisted 9.0. Use describe(). 1090 1074 1091 @type channel: C{str} 1075 1092 @param channel: The name of the channel to have an action on. If it 1076 1093 has no prefix, C{'#'} will to prepended to it. 1077 1094 @type action: C{str} 1078 1095 @param action: The action to preform. 1079 1096 """ 1097 warnings.warn("me() is deprecated since Twisted 9.0. Use IRCClient.describe().", 1098 DeprecationWarning, stacklevel=2) 1099 1080 1100 if channel[0] not in '&#!+': channel = '#' + channel 1081 self. ctcpMakeQuery(channel, [('ACTION', action)])1101 self.describe(channel, action) 1082 1102 1103 1083 1104 _pings = None 1084 1105 _MAX_PINGRING = 12 1085 1106