Пример #1
0
    def test_valid_date_string(self):
        "Test that when given a valid date string returns a datetime object"
        date = datetime.datetime(2010, 2, 1, 0, 0)
        date_string = "2010-02-01"
        date_format = "%Y-%m-%d"

        self.assertEqual(date, build_date(date_string, date_format))
Пример #2
0
 def __init__(self, **attrs):
     for attr in attrs:
         if attr == "date":
             attrs[attr] = build_date(attrs[attr], "%Y-%m-%d")
         setattr(self, attr, attrs[attr])