def test_datetime_to_literal(self): assert times.DateTime2literal(datetime(2015, 12, 13), '') == b"'2015-12-13 00:00:00'" assert times.DateTime2literal(datetime(2015, 12, 13, 11, 12, 13), '') == b"'2015-12-13 11:12:13'" assert times.DateTime2literal( datetime(2015, 12, 13, 11, 12, 13, 123456), '') == b"'2015-12-13 11:12:13.123456'"
def test_datetime_to_literal(self): self.assertEquals( times.DateTime2literal(datetime(2015, 12, 13), ""), b"'2015-12-13 00:00:00'" ) self.assertEquals( times.DateTime2literal(datetime(2015, 12, 13, 11, 12, 13), ""), b"'2015-12-13 11:12:13'", ) self.assertEquals( times.DateTime2literal(datetime(2015, 12, 13, 11, 12, 13, 123456), ""), b"'2015-12-13 11:12:13.123456'", )
def _escape_datetime(dt, c): return times.DateTime2literal(dt, c).decode('utf-8')