Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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"
Ejemplo n.º 4
0
 def testTimer(self):
    
    dtime().timer_start()
    pytime.sleep(2)
    dtime().timer_end()
    assert dtime().timer_result() > 1.9
    assert dtime().timer_result() < 2.1
Ejemplo n.º 5
0
 def testDatetimeObject(self):
    
    dt = dtime(self.iso_string)
    dto = dt.todatetime()
    assert type(dto) is pydatetime