tests/test_utils.py
branchpy33
changeset 3852 8318d362cddf
parent 3617 ae5744e97c42
child 4252 fe660f227cac
equal deleted inserted replaced
3851:f7397fb50684 3852:8318d362cddf
     4 __version__='''$Id$'''
     4 __version__='''$Id$'''
     5 __doc__="""Test reportlab.lib.util module"""
     5 __doc__="""Test reportlab.lib.util module"""
     6 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
     6 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
     7 setOutDir(__name__)
     7 setOutDir(__name__)
     8 import unittest
     8 import unittest
       
     9 from reportlab.lib.utils import FmtSelfDict, encode_label, decode_label
     9 
    10 
    10 class FmtTestCase(unittest.TestCase):
    11 class FmtTestCase(unittest.TestCase):
    11 
    12 
    12     def testFmt(self):
    13     def testFmt(self):
    13         from reportlab.lib.utils import FmtSelfDict
       
    14         class MixedIn(FmtSelfDict):
    14         class MixedIn(FmtSelfDict):
    15             def __init__(self):
    15             def __init__(self):
    16                 self.a = 'AA'
    16                 self.a = 'AA'
    17                 self._b = '_BB'
    17                 self._b = '_BB'
    18                 self.d = '(overridden)'
    18                 self.d = '(overridden)'
    23         self.assertEqual(
    23         self.assertEqual(
    24             'moon AA june_BB spoon %(a)sCC ni',
    24             'moon AA june_BB spoon %(a)sCC ni',
    25             obj._fmt('moon %(a)s june%(_b)s spoon %%(a)s%(c)s %(d)s', c='CC', C='boon', d='ni'))
    25             obj._fmt('moon %(a)s june%(_b)s spoon %%(a)s%(c)s %(d)s', c='CC', C='boon', d='ni'))
    26         self.assertRaises(AttributeError, obj._fmt, '%(c)s')  # XXX bit weird, can this be changed?
    26         self.assertRaises(AttributeError, obj._fmt, '%(c)s')  # XXX bit weird, can this be changed?
    27 
    27 
       
    28     def testLabelCoding(self):
       
    29         a = (1,2,[3,4],"a"), [1,2,"4",b'4']
       
    30         assert a == decode_label(encode_label(a))
    28 
    31 
    29 def makeSuite():
    32 def makeSuite():
    30     return makeSuiteForClasses(FmtTestCase)
    33     return makeSuiteForClasses(FmtTestCase)
    31 
    34 
    32 
    35