[Docstring-checkins] CVS: dps/test test_utils.py,1.6,1.7
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2002-03-13 02:40:08
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv1975/dps/test Modified Files: test_utils.py Log Message: updated Index: test_utils.py =================================================================== RCS file: /cvsroot/docstring/dps/test/test_utils.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_utils.py 11 Mar 2002 03:26:25 -0000 1.6 --- test_utils.py 13 Mar 2002 02:40:04 -0000 1.7 *************** *** 12,16 **** import unittest, StringIO, sys ! from DPSTestSupport import utils try: import mypdb as pdb --- 12,16 ---- import unittest, StringIO, sys ! from DPSTestSupport import utils, nodes try: import mypdb as pdb *************** *** 211,260 **** ! class AttributeParserTests(unittest.TestCase): ! def test_extractattributes(self): ! self.assertRaises(utils.BadAttributeLineError, ! utils.extractattributes, ['hello']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ['[hello]']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ['[=hello]']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ['[hello=]']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ['[hello="]']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ['[hello="something]']) ! self.assertRaises(utils.BadAttributeDataError, ! utils.extractattributes, ! ['[hello="something"else]']) ! output = utils.extractattributes("""\ ! [att1=val1 att2=val2 att3="value number '3'"] ! [att4=val4]""".splitlines()) self.assertEquals(output, [('att1', 'val1'), ('att2', 'val2'), ('att3', "value number '3'"), ('att4', 'val4')]) attributespec = {'a': int, 'bbb': float, 'cdef': lambda x: x} ! def test_assembleattributes(self): ! input = utils.extractattributes(['[a=1 bbb=2.0 cdef=hol%s]' ! % chr(224)]) self.assertEquals( ! utils.assembleattributes(input, self.attributespec), {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))}) ! input = utils.extractattributes(['[a=1 b=2.0 c=hol%s]' ! % chr(224)]) ! self.assertRaises(KeyError, utils.assembleattributes, input, self.attributespec) ! input = utils.extractattributes(['[a=1 bbb=two cdef=hol%s]' ! % chr(224)]) ! self.assertRaises(ValueError, utils.assembleattributes, input, self.attributespec) ! def test_parseattributes(self): ! input = ['[a=1 bbb=2.0 cdef=hol%s]' % chr(224)] self.assertEquals( ! utils.parseattributes(input, self.attributespec), {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))}) --- 211,268 ---- ! class NameValueTests(unittest.TestCase): ! def test_extract_name_value(self): ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! '=hello') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello=') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello="') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello="something') ! self.assertRaises(utils.NameValueError, utils.extract_name_value, ! 'hello="something"else') ! output = utils.extract_name_value( ! """att1=val1 att2=val2 att3="value number '3'" att4=val4""") self.assertEquals(output, [('att1', 'val1'), ('att2', 'val2'), ('att3', "value number '3'"), ('att4', 'val4')]) + + class ExtensionAttributeTests(unittest.TestCase): + attributespec = {'a': int, 'bbb': float, 'cdef': lambda x: x} ! def test_assemble_attribute_dict(self): ! input = utils.extract_name_value('a=1 bbb=2.0 cdef=hol%s' % chr(224)) self.assertEquals( ! utils.assemble_attribute_dict(input, self.attributespec), {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))}) ! input = utils.extract_name_value('a=1 b=2.0 c=hol%s' % chr(224)) ! self.assertRaises(KeyError, utils.assemble_attribute_dict, input, self.attributespec) ! input = utils.extract_name_value('a=1 bbb=two cdef=hol%s' % chr(224)) ! self.assertRaises(ValueError, utils.assemble_attribute_dict, input, self.attributespec) ! def test_extract_extension_attributes(self): ! field_list = nodes.field_list() ! field_list += nodes.field( ! '', nodes.field_name('', 'a'), ! nodes.field_body('', nodes.paragraph('', '1'))) ! field_list += nodes.field( ! '', nodes.field_name('', 'bbb'), ! nodes.field_body('', nodes.paragraph('', '2.0'))) ! field_list += nodes.field( ! '', nodes.field_name('', 'cdef'), ! nodes.field_body('', nodes.paragraph('', 'hol%s' % chr(224)))) self.assertEquals( ! utils.extract_extension_attributes(field_list, ! self.attributespec), {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))}) |