mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Rewrite of OptionListTestCase to actually test things well.
This commit is contained in:
parent
98cc71d5c9
commit
37247adcea
@ -41,22 +41,28 @@ if sqlite is not None:
|
|||||||
MoobotFactoids = Owner.loadPluginModule('MoobotFactoids')
|
MoobotFactoids = Owner.loadPluginModule('MoobotFactoids')
|
||||||
MF = MoobotFactoids
|
MF = MoobotFactoids
|
||||||
class OptionListTestCase(SupyTestCase):
|
class OptionListTestCase(SupyTestCase):
|
||||||
|
maxIterations = 267
|
||||||
|
def _testOptions(self, s, L):
|
||||||
|
max = self.maxIterations
|
||||||
|
original = L[:]
|
||||||
|
while max and L:
|
||||||
|
max -= 1
|
||||||
|
option = MF.pickOptions(s)
|
||||||
|
self.failUnless(option in original,
|
||||||
|
'Option %s not in %s' % (option, original))
|
||||||
|
if option in L:
|
||||||
|
L.remove(option)
|
||||||
|
self.failIf(L, 'Some options never seen: %s' % L)
|
||||||
|
|
||||||
def testPickOptions(self):
|
def testPickOptions(self):
|
||||||
for i in xrange(10):
|
self._testOptions('(a|b)', ['a', 'b'])
|
||||||
self.failUnless(MF.pickOptions('(a|b)') in ['a', 'b'])
|
self._testOptions('a', ['a'])
|
||||||
self.failUnless(MF.pickOptions('a') == 'a')
|
self._testOptions('(a|b (c|d))', ['a', 'b c', 'b d'])
|
||||||
self.failUnless(MF.pickOptions('(a|b (c|d))') in
|
self._testOptions('(a|(b|)c)', ['a', 'ab', 'cd', 'd'])
|
||||||
['a', 'b c', 'b d'])
|
self._testOptions('(a|(b|)|(c|)d)', ['a', 'ab', 'cd', 'd'])
|
||||||
self.failUnless(MF.pickOptions('(a|(b|)c)') in
|
self._testOptions('(a|)', ['a', ''])
|
||||||
['a', 'bc', 'c'])
|
self._testOptions('(|a)', ['a', ''])
|
||||||
self.failUnless(MF.pickOptions('(a(b|)|(c|)d)') in
|
self._testOptions('((a)|(b))', ['(a)', '(b)'])
|
||||||
['a', 'ab', 'cd', 'd'])
|
|
||||||
self.failUnless(MF.pickOptions('(a|)') in
|
|
||||||
['a', ''])
|
|
||||||
self.failUnless(MF.pickOptions('(|a)') in
|
|
||||||
['a', ''])
|
|
||||||
self.failUnless(MF.pickOptions('((a)|(b))') in
|
|
||||||
['(a)', '(b)'])
|
|
||||||
|
|
||||||
class FactoidsTestCase(PluginTestCase, PluginDocumentation):
|
class FactoidsTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('MoobotFactoids', 'User', 'Utilities')
|
plugins = ('MoobotFactoids', 'User', 'Utilities')
|
||||||
|
Loading…
Reference in New Issue
Block a user