Example #1
0
 def testStringDateFormatting(self):
     import DateTime
     html = String("%(name capitalize spacify)s is "
                   "%(date fmt=year)s/%(date fmt=month)s/%(date fmt=day)s")
     res = html(date=DateTime.DateTime("2001-04-27"), name='the_date')
     expected = 'The date is 2001/4/27'
     assert res == expected, res
 def testStringDateFormatting(self):
     import DateTime
     from DocumentTemplate.DT_HTML import String
     html = String("%(name capitalize spacify)s is "
                   "%(date fmt=year)s/%(date fmt=month)s/%(date fmt=day)s")
     res = html(date=DateTime.DateTime("2001-04-27"), name='the_date')
     expected = 'The date is 2001/4/27'
     self.assertEqual(res, expected)
Example #3
0
    def testBasicStringIn(self):
        data = (
            d(name='jim', age=39),
            d(name='kak', age=29),
            d(name='will', age=8),
            d(name='andrew', age=5),
            d(name='chessie', age=2),
        )
        s = """
%(in data mapping)[
   %(name)s, %(age)s
%(in)]
"""
        expected = """
   jim, 39
   kak, 29
   will, 8
   andrew, 5
   chessie, 2
"""
        result = String(s)(data=data)
        assert expected == result, result
Example #4
0
    def testBasicStringIn(self):
        from DocumentTemplate.DT_HTML import String
        data = (
            dict(name='jim', age=39),
            dict(name='kak', age=29),
            dict(name='will', age=8),
            dict(name='andrew', age=5),
            dict(name='chessie', age=2),
        )
        s = """
%(in data mapping)[
   %(name)s, %(age)s
%(in)]
"""
        expected = """
   jim, 39
   kak, 29
   will, 8
   andrew, 5
   chessie, 2
"""
        result = String(s)(data=data)
        self.assertEqual(result, expected)
Example #5
0
 def testSimpleString(self):
     from DocumentTemplate.DT_HTML import String
     dt = String('%(name)s')
     res = dt(name='Chris')
     expected = 'Chris'
     self.assertEqual(res, expected)
Example #6
0
 def testSimpleString(self):
     dt = String('%(name)s')
     res = dt(name='Chris')
     expected = 'Chris'
     assert res == expected, res
Example #7
0
 def testSimpleString(self):
     from DocumentTemplate.DT_HTML import String
     dt = String('%(name)s')
     res = dt(name='Chris')
     expected = 'Chris'
     assert res == expected, res