diff --git a/plugins/Channel/test.py b/plugins/Channel/test.py index 10c894824..9e3c9af31 100644 --- a/plugins/Channel/test.py +++ b/plugins/Channel/test.py @@ -233,7 +233,7 @@ class ChannelTestCase(ChannelPluginTestCase): self.assertNotRegexp('ban list foobar!*@baz', r'.*foo!bar@baz.*') self.assertRegexp('ban list foobar!*@baz', r'.*foobar!\*@baz.*') self.assertRegexp('ban list foobar!*@baz', r'.*foobar!qux@baz.*') - self.assertResponse('ban list foobar!\*@baz', + self.assertResponse('ban list foobar!*@baz', '"foobar!*@baz" (never expires)') def testIgnore(self): diff --git a/plugins/Factoids/test.py b/plugins/Factoids/test.py index 5209856f9..129c38c30 100644 --- a/plugins/Factoids/test.py +++ b/plugins/Factoids/test.py @@ -170,23 +170,23 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertNotError('learn moped is pretty fast') self.assertRegexp('moe', 'mooz.*moped') self.assertError('nosuchthing') - + def testWhatis(self): self.assertNotError('learn foo is bar') self.assertRegexp('whatis foo', 'bar') self.assertRegexp('whatis foob', 'foo') self.assertNotError('learn foob is barb') self.assertRegexp('whatis foom', 'foo.*foob') - + def testStandardSubstitute(self): self.assertNotError('learn foo is this is $channel, and hour is $hour') - self.assertRegexp('whatis foo', 'this is #test, and hour is \d{1,2}') - self.assertRegexp('whatis --raw foo', 'this is \$channel, and hour is \$hour') + self.assertRegexp('whatis foo', r'this is #test, and hour is \d{1,2}') + self.assertRegexp('whatis --raw foo', r'this is \$channel, and hour is \$hour') self.assertNotError('learn bar is this is $$channel escaped') - self.assertRegexp('whatis bar', 'this is \$channel') + self.assertRegexp('whatis bar', r'this is \$channel') self.assertNotError('learn bar is this is $minute') - self.assertRegexp('whatis bar', '\$channel.*\d{1,2}') - + self.assertRegexp('whatis bar', r'\$channel.*\d{1,2}') + def testAlias(self): self.assertNotError('learn foo is bar') self.assertNotError('alias foo zoog') @@ -195,19 +195,19 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertError('alias foo gnoop') self.assertNotError('alias foo gnoop 2') self.assertRegexp('whatis gnoop', 'snorp') - + def testRank(self): self.assertNotError('learn foo is bar') self.assertNotError('learn moo is cow') - self.assertRegexp('factoids rank', '#1 foo \(0\), #2 moo \(0\)') - self.assertRegexp('whatis moo', '.*cow.*') - self.assertRegexp('factoids rank', '#1 moo \(1\), #2 foo \(0\)') - self.assertRegexp('factoids rank 1', '#1 moo \(1\)') + self.assertRegexp('factoids rank', r'#1 foo \(0\), #2 moo \(0\)') + self.assertRegexp('whatis moo', r'.*cow.*') + self.assertRegexp('factoids rank', r'#1 moo \(1\), #2 foo \(0\)') + self.assertRegexp('factoids rank 1', r'#1 moo \(1\)') self.assertNotRegexp('factoids rank 1', 'foo') self.assertRegexp('factoids rank --plain', 'moo, foo') self.assertRegexp('factoids rank --plain --alpha', 'foo, moo') self.assertResponse('factoids rank --plain 1', 'moo') - + def testQuoteHandling(self): self.assertNotError('learn foo is "\\"bar\\""') self.assertRegexp('whatis foo', r'"bar"') diff --git a/plugins/MessageParser/test.py b/plugins/MessageParser/test.py index 22fc388ec..61c77a910 100644 --- a/plugins/MessageParser/test.py +++ b/plugins/MessageParser/test.py @@ -34,28 +34,28 @@ import sqlite3 class MessageParserTestCase(ChannelPluginTestCase): - plugins = ('MessageParser','Utilities','User') + plugins = ('MessageParser','Utilities','User') #utilities for the 'echo' #user for register for testVacuum - + def testAdd(self): self.assertError('messageparser add') #no args self.assertError('messageparser add "stuff"') #no action arg self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertRegexp('messageparser show "stuff"', '.*i saw some stuff.*') - + self.assertError('messageparser add "[a" "echo stuff"') #invalid regexp self.assertError('messageparser add "(a" "echo stuff"') #invalid regexp self.assertNotError('messageparser add "stuff" "echo i saw no stuff"') #overwrite existing regexp self.assertRegexp('messageparser show "stuff"', '.*i saw no stuff.*') - - + + try: world.testing = False origuser = self.prefix self.prefix = 'stuff!stuff@stuff' self.assertNotError('register nottester stuff', private=True) - + self.assertError('messageparser add "aoeu" "echo vowels are nice"') origconf = conf.supybot.plugins.MessageParser.requireManageCapability() conf.supybot.plugins.MessageParser.requireManageCapability.setValue('') @@ -84,13 +84,13 @@ class MessageParserTestCase(ChannelPluginTestCase): self.feedMsg('this a') self.assertResponse(' ', '$1') self.assertNotError('messageparser remove "this( .+)? a(.*)"') - + def testShow(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertRegexp('messageparser show "nostuff"', 'there is no such regexp trigger') self.assertRegexp('messageparser show "stuff"', '.*i saw some stuff.*') self.assertRegexp('messageparser show --id 1', '.*i saw some stuff.*') - + def testInfo(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertRegexp('messageparser info "nostuff"', 'there is no such regexp trigger') @@ -100,13 +100,13 @@ class MessageParserTestCase(ChannelPluginTestCase): self.feedMsg('this message has some stuff in it') self.getMsg(' ') self.assertRegexp('messageparser info "stuff"', 'has been triggered 1 times') - + def testTrigger(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.feedMsg('this message has some stuff in it') m = self.getMsg(' ') self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some stuff')) - + def testMaxTriggers(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertNotError('messageparser add "sbd" "echo i saw somebody"') @@ -129,7 +129,7 @@ class MessageParserTestCase(ChannelPluginTestCase): self.assertError('messageparser add "stuff" "echo some other stuff"') self.assertError('messageparser remove "stuff"') self.assertRegexp('messageparser info "stuff"', 'is locked') - + def testUnlock(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertNotError('messageparser lock "stuff"') @@ -137,26 +137,26 @@ class MessageParserTestCase(ChannelPluginTestCase): self.assertNotError('messageparser unlock "stuff"') self.assertRegexp('messageparser info "stuff"', 'is not locked') self.assertNotError('messageparser remove "stuff"') - + def testRank(self): - self.assertRegexp('messageparser rank', - 'There are no regexp triggers in the database\.') + self.assertRegexp('messageparser rank', + r'There are no regexp triggers in the database\.') self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') - self.assertRegexp('messageparser rank', '#1 "stuff" \(0\)') + self.assertRegexp('messageparser rank', r'#1 "stuff" \(0\)') self.assertNotError('messageparser add "aoeu" "echo vowels are nice!"') - self.assertRegexp('messageparser rank', '#1 "stuff" \(0\), #2 "aoeu" \(0\)') + self.assertRegexp('messageparser rank', r'#1 "stuff" \(0\), #2 "aoeu" \(0\)') self.feedMsg('instead of asdf, dvorak has aoeu') self.getMsg(' ') - self.assertRegexp('messageparser rank', '#1 "aoeu" \(1\), #2 "stuff" \(0\)') - + self.assertRegexp('messageparser rank', r'#1 "aoeu" \(1\), #2 "stuff" \(0\)') + def testList(self): - self.assertRegexp('messageparser list', - 'There are no regexp triggers in the database\.') + self.assertRegexp('messageparser list', + r'There are no regexp triggers in the database\.') self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertRegexp('messageparser list', '\x02#1\x02: stuff') self.assertNotError('messageparser add "aoeu" "echo vowels are nice!"') self.assertRegexp('messageparser list', '\x02#1\x02: stuff, \x02#2\x02: aoeu') - + def testRemove(self): self.assertError('messageparser remove "stuff"') self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') @@ -166,7 +166,7 @@ class MessageParserTestCase(ChannelPluginTestCase): self.assertNotError('messageparser remove "stuff"') self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertNotError('messageparser remove --id 1') - + def testVacuum(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertNotError('messageparser remove "stuff"') @@ -179,7 +179,7 @@ class MessageParserTestCase(ChannelPluginTestCase): self.prefix = 'stuff!stuff@stuff' self.assertNotError('register nottester stuff', private=True) self.assertError('messageparser vacuum') - + orig = conf.supybot.plugins.MessageParser.requireVacuumCapability() conf.supybot.plugins.MessageParser.requireVacuumCapability.setValue('') self.assertNotError('messageparser vacuum') @@ -187,10 +187,10 @@ class MessageParserTestCase(ChannelPluginTestCase): world.testing = True self.prefix = original conf.supybot.plugins.MessageParser.requireVacuumCapability.setValue(orig) - + def testKeepRankInfo(self): orig = conf.supybot.plugins.MessageParser.keepRankInfo() - + try: conf.supybot.plugins.MessageParser.keepRankInfo.setValue(False) self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') @@ -199,9 +199,9 @@ class MessageParserTestCase(ChannelPluginTestCase): self.assertRegexp('messageparser info "stuff"', 'has been triggered 0 times') finally: conf.supybot.plugins.MessageParser.keepRankInfo.setValue(orig) - + self.feedMsg('this message has some stuff in it') self.getMsg(' ') self.assertRegexp('messageparser info "stuff"', 'has been triggered 1 times') - + # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/plugins/Misc/test.py b/plugins/Misc/test.py index e2e359540..9532ed355 100644 --- a/plugins/Misc/test.py +++ b/plugins/Misc/test.py @@ -165,11 +165,11 @@ class MiscTestCase(ChannelPluginTestCase): conf.supybot.plugins.Misc.timestampFormat.setValue('') self.feedMsg('foo bar baz') self.assertResponse('last', '<%s> foo bar baz' % self.nick) - self.assertRegexp('last', '<%s> @last' % self.nick) + self.assertRegexp('last', r'<%s> @last' % self.nick) self.assertResponse('last --with foo', '<%s> foo bar baz' % \ self.nick) self.assertResponse('last --without foo', '<%s> @last' % self.nick) - self.assertRegexp('last --regexp m/\s+/', 'last --without foo') + self.assertRegexp(r'last --regexp m/\s+/', r'last --without foo') self.assertResponse('last --regexp m/bar/', '<%s> foo bar baz' % self.nick) self.assertResponse('last --from %s' % self.nick.upper(), diff --git a/plugins/MoobotFactoids/test.py b/plugins/MoobotFactoids/test.py index 48b2ed5bf..3275ca13a 100644 --- a/plugins/MoobotFactoids/test.py +++ b/plugins/MoobotFactoids/test.py @@ -144,7 +144,7 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertAction('moo3', 'foo') # Test and make sure it's parsing self.assertNotError('moo4 is (1|2|3)') - self.assertRegexp('moo4', '^(1|2|3)$') + self.assertRegexp('moo4', r'^(1|2|3)$') # Check case-insensitivity self.assertResponse('MOO', 'foo') self.assertResponse('mOo', 'foo') @@ -158,30 +158,30 @@ class FactoidsTestCase(ChannelPluginTestCase): def testFactinfo(self): self.assertNotError('moo is foo') - self.assertRegexp('factinfo moo', '^moo: Created by tester on.*$') + self.assertRegexp('factinfo moo', r'^moo: Created by tester on.*$') self.assertNotError('moo') - self.assertRegexp('factinfo moo', self.prefix + '.*1 time') + self.assertRegexp('factinfo moo', self.prefix + r'.*1 time') self.assertNotError('moo') - self.assertRegexp('factinfo moo', self.prefix + '.*2 times') + self.assertRegexp('factinfo moo', self.prefix + r'.*2 times') self.assertNotError('moo =~ s/foo/bar/') self.assertRegexp('factinfo moo', - '^moo: Created by tester on' - '.*?\. Last modified by tester on .*?\. ' - 'Last requested by %s on .*?, ' - 'requested 2 times.$' % self.prefix) + r'^moo: Created by tester on' + r'.*?\. Last modified by tester on .*?\. ' + r'Last requested by %s on .*?, ' + r'requested 2 times.$' % self.prefix) self.assertNotError('lock moo') self.assertRegexp('factinfo moo', - '^moo: Created by tester on' - '.*?\. Last modified by tester on .*?\. ' - 'Last requested by %s on .*?, ' - 'requested 2 times. ' - 'Locked by tester on .*\.$' % self.prefix) + r'^moo: Created by tester on' + r'.*?\. Last modified by tester on .*?\. ' + r'Last requested by %s on .*?, ' + r'requested 2 times. ' + r'Locked by tester on .*\.$' % self.prefix) self.assertNotError('unlock moo') self.assertRegexp('factinfo moo', - '^moo: Created by tester on' - '.*?\. Last modified by tester on .*?\. ' - 'Last requested by %s on .*?, ' - 'requested 2 times.$' % self.prefix) + r'^moo: Created by tester on' + r'.*?\. Last modified by tester on .*?\. ' + r'Last requested by %s on .*?, ' + r'requested 2 times.$' % self.prefix) # Make sure I solved this bug # Check and make sure all the other stuff is reset self.assertNotError('foo is bar') @@ -189,8 +189,8 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertNotError('foo') self.assertNotError('no foo is baz') self.assertRegexp('factinfo foo', - '^foo: Created by tester on' - '(?!(request|modif)).*?\.$') + r'^foo: Created by tester on' + r'(?!(request|modif)).*?\.$') def testLockUnlock(self): # disable world.testing since we want new users to not @@ -200,22 +200,22 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertNotError('moo is moo') self.assertNotError('lock moo') self.assertRegexp('factinfo moo', - '^moo: Created by tester on' - '.*?\. Locked by tester on .*?\.') + r'^moo: Created by tester on' + r'.*?\. Locked by tester on .*?\.') # switch user original = self.prefix self.prefix = 'moo!moo@moo' self.assertNotError('register nottester moo', private=True) self.assertError('unlock moo') self.assertRegexp('factinfo moo', - '^moo: Created by tester on' - '.*?\. Locked by tester on .*?\.') + r'^moo: Created by tester on' + r'.*?\. Locked by tester on .*?\.') # switch back self.prefix = original self.assertNotError('identify tester moo', private=True) self.assertNotError('unlock moo') self.assertRegexp('factinfo moo', - '^moo: Created by tester on.*?\.') + r'^moo: Created by tester on.*?\.') finally: world.testing = True @@ -246,10 +246,10 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertError('most popular') self.assertResponse('most authored', 'Most prolific author: moo (1)') - self.assertRegexp('most recent', "1 latest factoid:.*moogle") + self.assertRegexp('most recent', r"1 latest factoid:.*moogle") self.assertResponse('moogle', 'moo') self.assertRegexp('most popular', - "Top 1 requested factoid:.*moogle.*(1)") + r"Top 1 requested factoid:.*moogle.*(1)") # Check plural response time.sleep(1) self.prefix = userPrefix2 @@ -259,18 +259,18 @@ class FactoidsTestCase(ChannelPluginTestCase): r'(moo.*\(1\).*boo.*\(1\)' r'|boo.*\(1\).*moo.*\(1\))')) self.assertRegexp('most recent', - "2 latest factoids:.*mogle.*moogle.*") + r"2 latest factoids:.*mogle.*moogle.*") self.assertResponse('moogle', 'moo') self.assertRegexp('most popular', - "Top 1 requested factoid:.*moogle.*(2)") + r"Top 1 requested factoid:.*moogle.*(2)") self.assertResponse('mogle', 'mo') self.assertRegexp('most popular', - "Top 2 requested factoids:.*" - "moogle.*(2).*mogle.*(1)") + r"Top 2 requested factoids:.*" + r"moogle.*(2).*mogle.*(1)") # Check most author ordering self.assertNotError('moo is oom') self.assertRegexp('most authored', - 'Most prolific authors:.*boo.*(2).*moo.*(1)') + r'Most prolific authors:.*boo.*(2).*moo.*(1)') def testListkeys(self): self.assertResponse('listkeys %', 'No keys matching "%" found.') @@ -287,13 +287,13 @@ class FactoidsTestCase(ChannelPluginTestCase): for i in range(10): self.assertNotError('moo%s is moo' % i) self.assertRegexp('listkeys moo', - '^Key search for "moo" ' - '\(11 found\): ("moo\d*", )+and "moo9"$') + r'^Key search for "moo" ' + r'\(11 found\): ("moo\d*", )+and "moo9"$') self.assertNotError('foo is bar') self.assertRegexp('listkeys %', - '^Key search for "\%" ' - '\(12 found\): "foo", ("moo\d*", )+and ' - '"moo9"$') + r'^Key search for "\%" ' + r'\(12 found\): "foo", ("moo\d*", )+and ' + r'"moo9"$') # Check quoting self.assertNotError('foo\' is bar') self.assertResponse('listkeys foo', @@ -317,7 +317,7 @@ class FactoidsTestCase(ChannelPluginTestCase): def testListauth(self): self.assertNotError('moo is moo') - self.assertRegexp('listauth tester', 'tester.*\(1 found\):.*moo') + self.assertRegexp('listauth tester', r'tester.*\(1 found\):.*moo') self.assertError('listauth moo') def testRemove(self): diff --git a/plugins/String/test.py b/plugins/String/test.py index b3d5aec60..b22ce9145 100644 --- a/plugins/String/test.py +++ b/plugins/String/test.py @@ -116,9 +116,9 @@ class StringTestCase(PluginTestCase): self.assertResponse('re s/user/luser/g user user', 'luser luser') self.assertResponse('re s/user/luser/ user user', 'luser user') self.assertNotRegexp('re m/foo/ bar', 'has no attribute') - self.assertResponse('re m/a\S+y/ "the bot angryman is hairy"','angry') - self.assertResponse('re m/a\S+y/g "the bot angryman is hairy"', - 'angry and airy') + self.assertResponse('re m/a\\S+y/ "the bot angryman is hairy"', 'angry') + self.assertResponse('re m/a\\S+y/g "the bot angryman is hairy"', + 'angry and airy') def testReNotEmptyString(self): self.assertError('re s//foo/g blah') diff --git a/plugins/Todo/test.py b/plugins/Todo/test.py index 2567a1e0d..83f6f0505 100644 --- a/plugins/Todo/test.py +++ b/plugins/Todo/test.py @@ -50,7 +50,7 @@ class TodoTestCase(PluginTestCase): self.assertRegexp('todo', '#1: wash my car') # Check that task self.assertRegexp('todo 1', - 'Todo for tester: wash my car \(Added .*?\)') + r'Todo for tester: wash my car \(Added .*?\)') # Check that it lists all my tasks when given my name self.assertResponse('todo tester', 'Todo for tester: #1: wash my car') @@ -61,7 +61,7 @@ class TodoTestCase(PluginTestCase): # Check error self.assertError('todo asfas') self.assertRegexp('todo asfas', - 'Error: \'asfas\' is not a valid task') + 'Error: \'asfas\' is not a valid task') # Check priority sorting self.assertNotError('todo setpriority 1 100') self.assertNotError('todo setpriority 2 10') @@ -117,19 +117,19 @@ class TodoTestCase(PluginTestCase): def testSetPriority(self): self.assertNotError('todo add --priority=1 moo') self.assertRegexp('todo 1', - 'moo, priority: 1 \(Added at .*?\)') + r'moo, priority: 1 \(Added at .*?\)') self.assertNotError('setpriority 1 50') self.assertRegexp('todo 1', - 'moo, priority: 50 \(Added at .*?\)') + r'moo, priority: 50 \(Added at .*?\)') self.assertNotError('setpriority 1 0') - self.assertRegexp('todo 1', 'moo \(Added at .*?\)') + self.assertRegexp('todo 1', r'moo \(Added at .*?\)') def testChangeTodo(self): self.assertNotError('todo add moo') self.assertError('todo change 1 asdfas') self.assertError('todo change 1 m/asdfaf//') self.assertNotError('todo change 1 s/moo/foo/') - self.assertRegexp('todo 1', 'Todo for tester: foo \(Added .*?\)') + self.assertRegexp('todo 1', r'Todo for tester: foo \(Added .*?\)') def testActiveInactiveTodo(self): self.assertNotError('todo add foo') diff --git a/plugins/User/test.py b/plugins/User/test.py index 8990037d9..a9e8d1345 100644 --- a/plugins/User/test.py +++ b/plugins/User/test.py @@ -72,7 +72,7 @@ class UserTestCase(PluginTestCase): self.assertResponse('hostmask add bar *!*@foobar/*', 'Error: That hostmask is already registered to foo.', frm=self.prefix2) - self.assertRegexp('hostmask list foo', '\*!\*@foobar/b', + self.assertRegexp('hostmask list foo', r'\*!\*@foobar/b', frm=self.prefix1) self.assertNotRegexp('hostmask list bar', 'foobar', frm=self.prefix2)