def testSerializableAndBackAgain(self): dt = dtime(self.iso_string) assert type(dt.datetime) == dict assert dt.datetime['utctimestamp'] == 1455107663 s = json.dumps(dt.datetime) assert type(s) == str d = json.loads(s) dt = dtime(d) assert type(dt.datetime) == dict assert dt.datetime['utctimestamp'] == 1455107663
def testISOString(self): dt = dtime(self.utctimestamp) s = dt.toisostring() assert type(s) is str assert dt.datetime['year'] == 2016 assert dt.datetime['month'] == 2 assert dt.datetime['day'] == 10 assert s.find("Z") > -1
def testConstructor(self): dt = dtime(self.iso_string) assert type(dt) is not None assert dt.datetime['utctimestamp'] == 1455107663 dt = dtime(self.utctimestamp) assert type(dt) is not None dt = dtime(self.datetimeobject) assert type(dt) is not None assert dt.datetime['utctimestamp'] == 1455107663 dt = dtime(self.userdefined) assert type(dt) is not None assert dt.datetime['utctimestamp'] == 1455107663 dt = dtime() assert type(dt) is not None assert dt.__class__.OBJECT_NAME == "dtime"
def testTimer(self): dtime().timer_start() pytime.sleep(2) dtime().timer_end() assert dtime().timer_result() > 1.9 assert dtime().timer_result() < 2.1
def testDatetimeObject(self): dt = dtime(self.iso_string) dto = dt.todatetime() assert type(dto) is pydatetime