mercredi 31 août 2016

How can I unit test a method using a datetime?

I have the follow class and method:

class DateTimeHelper(object):

    @staticmethod
    def get_utc_millisecond_timestamp():
        (dt, micro) = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f').split('.')
        return "%s.%03d" % (dt, int(micro) / 1000)  # UTC time with millisecond

How can I unit test it? I am completely stumped although this is simple. It's my first unit test.

Aucun commentaire:

Enregistrer un commentaire