Back to index

moin  1.9.0~rc2
Public Member Functions
MoinMoin._tests.test_wikiutil.TestArgGetters Class Reference

List of all members.

Public Member Functions

def testGetBoolean
def testGetBooleanRaising
def testGetInt
def testGetIntRaising
def testGetFloat
def testGetFloatRaising
def testGetComplex
def testGetComplexRaising
def testGetUnicode
def testGetUnicodeRaising

Detailed Description

Definition at line 515 of file test_wikiutil.py.


Member Function Documentation

Definition at line 516 of file test_wikiutil.py.

00516 
00517     def testGetBoolean(self):
00518         tests = [
00519             # default testing for None value
00520             (None, None, None, None),
00521             (None, None, False, False),
00522             (None, None, True, True),
00523 
00524             # some real values
00525             (u'0', None, None, False),
00526             (u'1', None, None, True),
00527             (u'false', None, None, False),
00528             (u'true', None, None, True),
00529             (u'FALSE', None, None, False),
00530             (u'TRUE', None, None, True),
00531             (u'no', None, None, False),
00532             (u'yes', None, None, True),
00533             (u'NO', None, None, False),
00534             (u'YES', None, None, True),
00535         ]
00536         for arg, name, default, expected in tests:
00537             assert wikiutil.get_bool(self.request, arg, name, default) == expected

Here is the call graph for this function:

Definition at line 538 of file test_wikiutil.py.

00538 
00539     def testGetBooleanRaising(self):
00540         # wrong default type
00541         py.test.raises(AssertionError, wikiutil.get_bool, self.request, None, None, 42)
00542 
00543         # anything except None or unicode raises TypeError
00544         py.test.raises(TypeError, wikiutil.get_bool, self.request, True)
00545         py.test.raises(TypeError, wikiutil.get_bool, self.request, 42)
00546         py.test.raises(TypeError, wikiutil.get_bool, self.request, 42.0)
00547         py.test.raises(TypeError, wikiutil.get_bool, self.request, '')
00548         py.test.raises(TypeError, wikiutil.get_bool, self.request, tuple())
00549         py.test.raises(TypeError, wikiutil.get_bool, self.request, [])
00550         py.test.raises(TypeError, wikiutil.get_bool, self.request, {})
00551 
00552         # any value not convertable to boolean raises ValueError
00553         py.test.raises(ValueError, wikiutil.get_bool, self.request, u'')
00554         py.test.raises(ValueError, wikiutil.get_bool, self.request, u'42')
00555         py.test.raises(ValueError, wikiutil.get_bool, self.request, u'wrong')
00556         py.test.raises(ValueError, wikiutil.get_bool, self.request, u'"True"') # must not be quoted!

Here is the call graph for this function:

Definition at line 626 of file test_wikiutil.py.

00626 
00627     def testGetComplex(self):
00628         tests = [
00629             # default testing for None value
00630             (None, None, None, None),
00631             (None, None, -23.42, -23.42),
00632             (None, None, 42.23, 42.23),
00633 
00634             # some real values
00635             (u'0', None, None, 0),
00636             (u'42.23', None, None, 42.23),
00637             (u'-23.42', None, None, -23.42),
00638             (u'-23.42E3', None, None, -23.42E3),
00639             (u'23.42E-3', None, None, 23.42E-3),
00640             (u'23.42E-3+3.04j', None, None, 23.42E-3+3.04j),
00641             (u'3.04j', None, None, 3.04j),
00642             (u'-3.04j', None, None, -3.04j),
00643             (u'23.42E-3+3.04i', None, None, 23.42E-3+3.04j),
00644             (u'3.04i', None, None, 3.04j),
00645             (u'-3.04i', None, None, -3.04j),
00646             (u'-3', None, None, -3L),
00647             (u'-300000000000000000000', None, None, -300000000000000000000L),
00648         ]
00649         for arg, name, default, expected in tests:
00650             assert wikiutil.get_complex(self.request, arg, name, default) == expected

Here is the call graph for this function:

Definition at line 651 of file test_wikiutil.py.

00651 
00652     def testGetComplexRaising(self):
00653         # wrong default type
00654         py.test.raises(AssertionError, wikiutil.get_complex, self.request, None, None, u'42')
00655 
00656         # anything except None or unicode raises TypeError
00657         py.test.raises(TypeError, wikiutil.get_complex, self.request, True)
00658         py.test.raises(TypeError, wikiutil.get_complex, self.request, 42)
00659         py.test.raises(TypeError, wikiutil.get_complex, self.request, 42.0)
00660         py.test.raises(TypeError, wikiutil.get_complex, self.request, 3j)
00661         py.test.raises(TypeError, wikiutil.get_complex, self.request, '')
00662         py.test.raises(TypeError, wikiutil.get_complex, self.request, tuple())
00663         py.test.raises(TypeError, wikiutil.get_complex, self.request, [])
00664         py.test.raises(TypeError, wikiutil.get_complex, self.request, {})
00665 
00666         # any value not convertable to int raises ValueError
00667         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'')
00668         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'3jj')
00669         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'3Ij')
00670         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'3i-3i')
00671         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'wrong')
00672         py.test.raises(ValueError, wikiutil.get_complex, self.request, u'"47.11"') # must not be quoted!

Here is the call graph for this function:

Definition at line 591 of file test_wikiutil.py.

00591 
00592     def testGetFloat(self):
00593         tests = [
00594             # default testing for None value
00595             (None, None, None, None),
00596             (None, None, -23.42, -23.42),
00597             (None, None, 42.23, 42.23),
00598 
00599             # some real values
00600             (u'0', None, None, 0),
00601             (u'42.23', None, None, 42.23),
00602             (u'-23.42', None, None, -23.42),
00603             (u'-23.42E3', None, None, -23.42E3),
00604             (u'23.42E-3', None, None, 23.42E-3),
00605         ]
00606         for arg, name, default, expected in tests:
00607             assert wikiutil.get_float(self.request, arg, name, default) == expected

Here is the call graph for this function:

Definition at line 608 of file test_wikiutil.py.

00608 
00609     def testGetFloatRaising(self):
00610         # wrong default type
00611         py.test.raises(AssertionError, wikiutil.get_float, self.request, None, None, u'42')
00612 
00613         # anything except None or unicode raises TypeError
00614         py.test.raises(TypeError, wikiutil.get_float, self.request, True)
00615         py.test.raises(TypeError, wikiutil.get_float, self.request, 42)
00616         py.test.raises(TypeError, wikiutil.get_float, self.request, 42.0)
00617         py.test.raises(TypeError, wikiutil.get_float, self.request, '')
00618         py.test.raises(TypeError, wikiutil.get_float, self.request, tuple())
00619         py.test.raises(TypeError, wikiutil.get_float, self.request, [])
00620         py.test.raises(TypeError, wikiutil.get_float, self.request, {})
00621 
00622         # any value not convertable to int raises ValueError
00623         py.test.raises(ValueError, wikiutil.get_float, self.request, u'')
00624         py.test.raises(ValueError, wikiutil.get_float, self.request, u'wrong')
00625         py.test.raises(ValueError, wikiutil.get_float, self.request, u'"47.11"') # must not be quoted!

Here is the call graph for this function:

Definition at line 557 of file test_wikiutil.py.

00557 
00558     def testGetInt(self):
00559         tests = [
00560             # default testing for None value
00561             (None, None, None, None),
00562             (None, None, -23, -23),
00563             (None, None, 42, 42),
00564 
00565             # some real values
00566             (u'0', None, None, 0),
00567             (u'42', None, None, 42),
00568             (u'-23', None, None, -23),
00569         ]
00570         for arg, name, default, expected in tests:
00571             assert wikiutil.get_int(self.request, arg, name, default) == expected

Here is the call graph for this function:

Definition at line 572 of file test_wikiutil.py.

00572 
00573     def testGetIntRaising(self):
00574         # wrong default type
00575         py.test.raises(AssertionError, wikiutil.get_int, self.request, None, None, 42.23)
00576 
00577         # anything except None or unicode raises TypeError
00578         py.test.raises(TypeError, wikiutil.get_int, self.request, True)
00579         py.test.raises(TypeError, wikiutil.get_int, self.request, 42)
00580         py.test.raises(TypeError, wikiutil.get_int, self.request, 42.0)
00581         py.test.raises(TypeError, wikiutil.get_int, self.request, '')
00582         py.test.raises(TypeError, wikiutil.get_int, self.request, tuple())
00583         py.test.raises(TypeError, wikiutil.get_int, self.request, [])
00584         py.test.raises(TypeError, wikiutil.get_int, self.request, {})
00585 
00586         # any value not convertable to int raises ValueError
00587         py.test.raises(ValueError, wikiutil.get_int, self.request, u'')
00588         py.test.raises(ValueError, wikiutil.get_int, self.request, u'23.42')
00589         py.test.raises(ValueError, wikiutil.get_int, self.request, u'wrong')
00590         py.test.raises(ValueError, wikiutil.get_int, self.request, u'"4711"') # must not be quoted!

Here is the call graph for this function:

Definition at line 673 of file test_wikiutil.py.

00673 
00674     def testGetUnicode(self):
00675         tests = [
00676             # default testing for None value
00677             (None, None, None, None),
00678             (None, None, u'', u''),
00679             (None, None, u'abc', u'abc'),
00680 
00681             # some real values
00682             (u'', None, None, u''),
00683             (u'abc', None, None, u'abc'),
00684             (u'"abc"', None, None, u'"abc"'),
00685         ]
00686         for arg, name, default, expected in tests:
00687             assert wikiutil.get_unicode(self.request, arg, name, default) == expected

Here is the call graph for this function:

Definition at line 688 of file test_wikiutil.py.

00688 
00689     def testGetUnicodeRaising(self):
00690         # wrong default type
00691         py.test.raises(AssertionError, wikiutil.get_unicode, self.request, None, None, 42)
00692 
00693         # anything except None or unicode raises TypeError
00694         py.test.raises(TypeError, wikiutil.get_unicode, self.request, True)
00695         py.test.raises(TypeError, wikiutil.get_unicode, self.request, 42)
00696         py.test.raises(TypeError, wikiutil.get_unicode, self.request, 42.0)
00697         py.test.raises(TypeError, wikiutil.get_unicode, self.request, '')
00698         py.test.raises(TypeError, wikiutil.get_unicode, self.request, tuple())
00699         py.test.raises(TypeError, wikiutil.get_unicode, self.request, [])
00700         py.test.raises(TypeError, wikiutil.get_unicode, self.request, {})
00701 

Here is the call graph for this function:


The documentation for this class was generated from the following file: