plugins: use r'' strings to fix DeprecationWarning in test cases (#1328)

This commit is contained in:
James Lu 2020-01-26 11:14:21 -08:00
parent ff899f5158
commit 772862d49c
8 changed files with 90 additions and 90 deletions

View File

@ -233,7 +233,7 @@ class ChannelTestCase(ChannelPluginTestCase):
self.assertNotRegexp('ban list foobar!*@baz', r'.*foo!bar@baz.*') 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!\*@baz.*')
self.assertRegexp('ban list foobar!*@baz', r'.*foobar!qux@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)') '"foobar!*@baz" (never expires)')
def testIgnore(self): def testIgnore(self):

View File

@ -180,12 +180,12 @@ class FactoidsTestCase(ChannelPluginTestCase):
def testStandardSubstitute(self): def testStandardSubstitute(self):
self.assertNotError('learn foo is this is $channel, and hour is $hour') 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 foo', r'this is #test, and hour is \d{1,2}')
self.assertRegexp('whatis --raw foo', 'this is \$channel, and hour is \$hour') self.assertRegexp('whatis --raw foo', r'this is \$channel, and hour is \$hour')
self.assertNotError('learn bar is this is $$channel escaped') 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.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): def testAlias(self):
self.assertNotError('learn foo is bar') self.assertNotError('learn foo is bar')
@ -199,10 +199,10 @@ class FactoidsTestCase(ChannelPluginTestCase):
def testRank(self): def testRank(self):
self.assertNotError('learn foo is bar') self.assertNotError('learn foo is bar')
self.assertNotError('learn moo is cow') self.assertNotError('learn moo is cow')
self.assertRegexp('factoids rank', '#1 foo \(0\), #2 moo \(0\)') self.assertRegexp('factoids rank', r'#1 foo \(0\), #2 moo \(0\)')
self.assertRegexp('whatis moo', '.*cow.*') self.assertRegexp('whatis moo', r'.*cow.*')
self.assertRegexp('factoids rank', '#1 moo \(1\), #2 foo \(0\)') self.assertRegexp('factoids rank', r'#1 moo \(1\), #2 foo \(0\)')
self.assertRegexp('factoids rank 1', '#1 moo \(1\)') self.assertRegexp('factoids rank 1', r'#1 moo \(1\)')
self.assertNotRegexp('factoids rank 1', 'foo') self.assertNotRegexp('factoids rank 1', 'foo')
self.assertRegexp('factoids rank --plain', 'moo, foo') self.assertRegexp('factoids rank --plain', 'moo, foo')
self.assertRegexp('factoids rank --plain --alpha', 'foo, moo') self.assertRegexp('factoids rank --plain --alpha', 'foo, moo')

View File

@ -140,18 +140,18 @@ class MessageParserTestCase(ChannelPluginTestCase):
def testRank(self): def testRank(self):
self.assertRegexp('messageparser rank', self.assertRegexp('messageparser rank',
'There are no regexp triggers in the database\.') r'There are no regexp triggers in the database\.')
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') 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.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.feedMsg('instead of asdf, dvorak has aoeu')
self.getMsg(' ') 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): def testList(self):
self.assertRegexp('messageparser list', self.assertRegexp('messageparser list',
'There are no regexp triggers in the database\.') r'There are no regexp triggers in the database\.')
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
self.assertRegexp('messageparser list', '\x02#1\x02: stuff') self.assertRegexp('messageparser list', '\x02#1\x02: stuff')
self.assertNotError('messageparser add "aoeu" "echo vowels are nice!"') self.assertNotError('messageparser add "aoeu" "echo vowels are nice!"')

View File

@ -165,11 +165,11 @@ class MiscTestCase(ChannelPluginTestCase):
conf.supybot.plugins.Misc.timestampFormat.setValue('') conf.supybot.plugins.Misc.timestampFormat.setValue('')
self.feedMsg('foo bar baz') self.feedMsg('foo bar baz')
self.assertResponse('last', '<%s> foo bar baz' % self.nick) 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.assertResponse('last --with foo', '<%s> foo bar baz' % \
self.nick) self.nick)
self.assertResponse('last --without foo', '<%s> @last' % 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/', self.assertResponse('last --regexp m/bar/',
'<%s> foo bar baz' % self.nick) '<%s> foo bar baz' % self.nick)
self.assertResponse('last --from %s' % self.nick.upper(), self.assertResponse('last --from %s' % self.nick.upper(),

View File

@ -144,7 +144,7 @@ class FactoidsTestCase(ChannelPluginTestCase):
self.assertAction('moo3', 'foo') self.assertAction('moo3', 'foo')
# Test and make sure it's parsing # Test and make sure it's parsing
self.assertNotError('moo4 is <reply>(1|2|3)') self.assertNotError('moo4 is <reply>(1|2|3)')
self.assertRegexp('moo4', '^(1|2|3)$') self.assertRegexp('moo4', r'^(1|2|3)$')
# Check case-insensitivity # Check case-insensitivity
self.assertResponse('MOO', 'foo') self.assertResponse('MOO', 'foo')
self.assertResponse('mOo', 'foo') self.assertResponse('mOo', 'foo')
@ -158,30 +158,30 @@ class FactoidsTestCase(ChannelPluginTestCase):
def testFactinfo(self): def testFactinfo(self):
self.assertNotError('moo is <reply>foo') self.assertNotError('moo is <reply>foo')
self.assertRegexp('factinfo moo', '^moo: Created by tester on.*$') self.assertRegexp('factinfo moo', r'^moo: Created by tester on.*$')
self.assertNotError('moo') self.assertNotError('moo')
self.assertRegexp('factinfo moo', self.prefix + '.*1 time') self.assertRegexp('factinfo moo', self.prefix + r'.*1 time')
self.assertNotError('moo') 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.assertNotError('moo =~ s/foo/bar/')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on' r'^moo: Created by tester on'
'.*?\. Last modified by tester on .*?\. ' r'.*?\. Last modified by tester on .*?\. '
'Last requested by %s on .*?, ' r'Last requested by %s on .*?, '
'requested 2 times.$' % self.prefix) r'requested 2 times.$' % self.prefix)
self.assertNotError('lock moo') self.assertNotError('lock moo')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on' r'^moo: Created by tester on'
'.*?\. Last modified by tester on .*?\. ' r'.*?\. Last modified by tester on .*?\. '
'Last requested by %s on .*?, ' r'Last requested by %s on .*?, '
'requested 2 times. ' r'requested 2 times. '
'Locked by tester on .*\.$' % self.prefix) r'Locked by tester on .*\.$' % self.prefix)
self.assertNotError('unlock moo') self.assertNotError('unlock moo')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on' r'^moo: Created by tester on'
'.*?\. Last modified by tester on .*?\. ' r'.*?\. Last modified by tester on .*?\. '
'Last requested by %s on .*?, ' r'Last requested by %s on .*?, '
'requested 2 times.$' % self.prefix) r'requested 2 times.$' % self.prefix)
# Make sure I solved this bug # Make sure I solved this bug
# Check and make sure all the other stuff is reset # Check and make sure all the other stuff is reset
self.assertNotError('foo is bar') self.assertNotError('foo is bar')
@ -189,8 +189,8 @@ class FactoidsTestCase(ChannelPluginTestCase):
self.assertNotError('foo') self.assertNotError('foo')
self.assertNotError('no foo is baz') self.assertNotError('no foo is baz')
self.assertRegexp('factinfo foo', self.assertRegexp('factinfo foo',
'^foo: Created by tester on' r'^foo: Created by tester on'
'(?!(request|modif)).*?\.$') r'(?!(request|modif)).*?\.$')
def testLockUnlock(self): def testLockUnlock(self):
# disable world.testing since we want new users to not # disable world.testing since we want new users to not
@ -200,22 +200,22 @@ class FactoidsTestCase(ChannelPluginTestCase):
self.assertNotError('moo is <reply>moo') self.assertNotError('moo is <reply>moo')
self.assertNotError('lock moo') self.assertNotError('lock moo')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on' r'^moo: Created by tester on'
'.*?\. Locked by tester on .*?\.') r'.*?\. Locked by tester on .*?\.')
# switch user # switch user
original = self.prefix original = self.prefix
self.prefix = 'moo!moo@moo' self.prefix = 'moo!moo@moo'
self.assertNotError('register nottester moo', private=True) self.assertNotError('register nottester moo', private=True)
self.assertError('unlock moo') self.assertError('unlock moo')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on' r'^moo: Created by tester on'
'.*?\. Locked by tester on .*?\.') r'.*?\. Locked by tester on .*?\.')
# switch back # switch back
self.prefix = original self.prefix = original
self.assertNotError('identify tester moo', private=True) self.assertNotError('identify tester moo', private=True)
self.assertNotError('unlock moo') self.assertNotError('unlock moo')
self.assertRegexp('factinfo moo', self.assertRegexp('factinfo moo',
'^moo: Created by tester on.*?\.') r'^moo: Created by tester on.*?\.')
finally: finally:
world.testing = True world.testing = True
@ -246,10 +246,10 @@ class FactoidsTestCase(ChannelPluginTestCase):
self.assertError('most popular') self.assertError('most popular')
self.assertResponse('most authored', self.assertResponse('most authored',
'Most prolific author: moo (1)') '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.assertResponse('moogle', 'moo')
self.assertRegexp('most popular', self.assertRegexp('most popular',
"Top 1 requested factoid:.*moogle.*(1)") r"Top 1 requested factoid:.*moogle.*(1)")
# Check plural response # Check plural response
time.sleep(1) time.sleep(1)
self.prefix = userPrefix2 self.prefix = userPrefix2
@ -259,18 +259,18 @@ class FactoidsTestCase(ChannelPluginTestCase):
r'(moo.*\(1\).*boo.*\(1\)' r'(moo.*\(1\).*boo.*\(1\)'
r'|boo.*\(1\).*moo.*\(1\))')) r'|boo.*\(1\).*moo.*\(1\))'))
self.assertRegexp('most recent', self.assertRegexp('most recent',
"2 latest factoids:.*mogle.*moogle.*") r"2 latest factoids:.*mogle.*moogle.*")
self.assertResponse('moogle', 'moo') self.assertResponse('moogle', 'moo')
self.assertRegexp('most popular', self.assertRegexp('most popular',
"Top 1 requested factoid:.*moogle.*(2)") r"Top 1 requested factoid:.*moogle.*(2)")
self.assertResponse('mogle', 'mo') self.assertResponse('mogle', 'mo')
self.assertRegexp('most popular', self.assertRegexp('most popular',
"Top 2 requested factoids:.*" r"Top 2 requested factoids:.*"
"moogle.*(2).*mogle.*(1)") r"moogle.*(2).*mogle.*(1)")
# Check most author ordering # Check most author ordering
self.assertNotError('moo is <reply>oom') self.assertNotError('moo is <reply>oom')
self.assertRegexp('most authored', self.assertRegexp('most authored',
'Most prolific authors:.*boo.*(2).*moo.*(1)') r'Most prolific authors:.*boo.*(2).*moo.*(1)')
def testListkeys(self): def testListkeys(self):
self.assertResponse('listkeys %', 'No keys matching "%" found.') self.assertResponse('listkeys %', 'No keys matching "%" found.')
@ -287,13 +287,13 @@ class FactoidsTestCase(ChannelPluginTestCase):
for i in range(10): for i in range(10):
self.assertNotError('moo%s is <reply>moo' % i) self.assertNotError('moo%s is <reply>moo' % i)
self.assertRegexp('listkeys moo', self.assertRegexp('listkeys moo',
'^Key search for "moo" ' r'^Key search for "moo" '
'\(11 found\): ("moo\d*", )+and "moo9"$') r'\(11 found\): ("moo\d*", )+and "moo9"$')
self.assertNotError('foo is bar') self.assertNotError('foo is bar')
self.assertRegexp('listkeys %', self.assertRegexp('listkeys %',
'^Key search for "\%" ' r'^Key search for "\%" '
'\(12 found\): "foo", ("moo\d*", )+and ' r'\(12 found\): "foo", ("moo\d*", )+and '
'"moo9"$') r'"moo9"$')
# Check quoting # Check quoting
self.assertNotError('foo\' is bar') self.assertNotError('foo\' is bar')
self.assertResponse('listkeys foo', self.assertResponse('listkeys foo',
@ -317,7 +317,7 @@ class FactoidsTestCase(ChannelPluginTestCase):
def testListauth(self): def testListauth(self):
self.assertNotError('moo is <reply>moo') self.assertNotError('moo is <reply>moo')
self.assertRegexp('listauth tester', 'tester.*\(1 found\):.*moo') self.assertRegexp('listauth tester', r'tester.*\(1 found\):.*moo')
self.assertError('listauth moo') self.assertError('listauth moo')
def testRemove(self): def testRemove(self):

View File

@ -116,9 +116,9 @@ class StringTestCase(PluginTestCase):
self.assertResponse('re s/user/luser/g user user', 'luser luser') self.assertResponse('re s/user/luser/g user user', 'luser luser')
self.assertResponse('re s/user/luser/ user user', 'luser user') self.assertResponse('re s/user/luser/ user user', 'luser user')
self.assertNotRegexp('re m/foo/ bar', 'has no attribute') 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/ "the bot angryman is hairy"', 'angry')
self.assertResponse('re m/a\S+y/g "the bot angryman is hairy"', self.assertResponse('re m/a\\S+y/g "the bot angryman is hairy"',
'angry and airy') 'angry and airy')
def testReNotEmptyString(self): def testReNotEmptyString(self):
self.assertError('re s//foo/g blah') self.assertError('re s//foo/g blah')

View File

@ -50,7 +50,7 @@ class TodoTestCase(PluginTestCase):
self.assertRegexp('todo', '#1: wash my car') self.assertRegexp('todo', '#1: wash my car')
# Check that task # Check that task
self.assertRegexp('todo 1', 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 # Check that it lists all my tasks when given my name
self.assertResponse('todo tester', self.assertResponse('todo tester',
'Todo for tester: #1: wash my car') 'Todo for tester: #1: wash my car')
@ -61,7 +61,7 @@ class TodoTestCase(PluginTestCase):
# Check error # Check error
self.assertError('todo asfas') self.assertError('todo asfas')
self.assertRegexp('todo asfas', self.assertRegexp('todo asfas',
'Error: \'asfas\' is not a valid task') 'Error: \'asfas\' is not a valid task')
# Check priority sorting # Check priority sorting
self.assertNotError('todo setpriority 1 100') self.assertNotError('todo setpriority 1 100')
self.assertNotError('todo setpriority 2 10') self.assertNotError('todo setpriority 2 10')
@ -117,19 +117,19 @@ class TodoTestCase(PluginTestCase):
def testSetPriority(self): def testSetPriority(self):
self.assertNotError('todo add --priority=1 moo') self.assertNotError('todo add --priority=1 moo')
self.assertRegexp('todo 1', self.assertRegexp('todo 1',
'moo, priority: 1 \(Added at .*?\)') r'moo, priority: 1 \(Added at .*?\)')
self.assertNotError('setpriority 1 50') self.assertNotError('setpriority 1 50')
self.assertRegexp('todo 1', self.assertRegexp('todo 1',
'moo, priority: 50 \(Added at .*?\)') r'moo, priority: 50 \(Added at .*?\)')
self.assertNotError('setpriority 1 0') self.assertNotError('setpriority 1 0')
self.assertRegexp('todo 1', 'moo \(Added at .*?\)') self.assertRegexp('todo 1', r'moo \(Added at .*?\)')
def testChangeTodo(self): def testChangeTodo(self):
self.assertNotError('todo add moo') self.assertNotError('todo add moo')
self.assertError('todo change 1 asdfas') self.assertError('todo change 1 asdfas')
self.assertError('todo change 1 m/asdfaf//') self.assertError('todo change 1 m/asdfaf//')
self.assertNotError('todo change 1 s/moo/foo/') 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): def testActiveInactiveTodo(self):
self.assertNotError('todo add foo') self.assertNotError('todo add foo')

View File

@ -72,7 +72,7 @@ class UserTestCase(PluginTestCase):
self.assertResponse('hostmask add bar *!*@foobar/*', self.assertResponse('hostmask add bar *!*@foobar/*',
'Error: That hostmask is already registered to foo.', 'Error: That hostmask is already registered to foo.',
frm=self.prefix2) frm=self.prefix2)
self.assertRegexp('hostmask list foo', '\*!\*@foobar/b', self.assertRegexp('hostmask list foo', r'\*!\*@foobar/b',
frm=self.prefix1) frm=self.prefix1)
self.assertNotRegexp('hostmask list bar', 'foobar', self.assertNotRegexp('hostmask list bar', 'foobar',
frm=self.prefix2) frm=self.prefix2)