'Test date parsing'

def testDateParsingPersian(self):

    assertEqual = self.assertEqual
    assertRaises = self.assertRaises
    now = current.request.utcnow
    today = (now.year, now.month, now.day, 0, 0, 0)
    c = S3Calendar('Persian')
    (cyear, cmonth, cday) = c.calendar._cdate(today)[:3]
    test_dates = (('%Y-%m-%d', '1352-02-01', (1352, 2, 1, 0, 0, 0)), ('%d.%m.%Y', '18.5.1384', (1384, 5, 18, 0, 0, 0)), ('%d/%m/%y', None, 'TypeError'), ('%d/%m/%y', '32.04.1378', 'ValueError'), ('%d.%m.%Y', '32.04.1378', 'ValueError'), ('%d/%m/%y', '31/7/84', (1384, 8, 1, 0, 0, 0)), ('%d/%m/%y', '30/12/84', (1385, 1, 1, 0, 0, 0)), ('%d/%m/%Y', '16/04/78', (78, 4, 16, 0, 0, 0)), ('%d.%B', '16.    Shahrivar', (cyear, 6, 16, 0, 0, 0)), ('%d-%b-%Y', '27-Tir-1393', (1393, 4, 27, 0, 0, 0)))
    for (dtfmt, string, timetuple) in test_dates:
        parser = S3DateTimeParser(c, dtfmt)
        if (timetuple == 'ValueError'):
            with assertRaises(ValueError):
                result = parser.parse(string)
        elif (timetuple == 'TypeError'):
            with assertRaises(TypeError):
                result = parser.parse(string)
        else:
            result = parser.parse(string)
            assertEqual(result, timetuple)
