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.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):

View File

@ -180,12 +180,12 @@ class FactoidsTestCase(ChannelPluginTestCase):
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')
@ -199,10 +199,10 @@ class FactoidsTestCase(ChannelPluginTestCase):
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')

View File

@ -140,18 +140,18 @@ class MessageParserTestCase(ChannelPluginTestCase):
def testRank(self):
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.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\.')
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!"')

View File

@ -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(),

View File

@ -144,7 +144,7 @@ class FactoidsTestCase(ChannelPluginTestCase):
self.assertAction('moo3', 'foo')
# Test and make sure it's parsing
self.assertNotError('moo4 is <reply>(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 <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.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 <reply>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 <reply>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 <reply>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 <reply>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):

View File

@ -116,8 +116,8 @@ 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"',
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):

View File

@ -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')
@ -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')

View File

@ -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)