def test_boottime_calc(self): psi_bt = psi.boottime() calc_bt = time.time() - psi.uptime().timestamp() calc_min = calc_bt - 2 calc_max = calc_bt + 2 self.assert_(calc_min < psi_bt.timestamp() < calc_max, '%s < %s < %s' % (calc_min, psi_bt.timestamp(), calc_max))
def test_uptime_calc(self): psi_uptime = psi.uptime().timestamp() calc_uptime = time.time() - psi.boottime().timestamp() calc_min = calc_uptime - 2 calc_max = calc_uptime + 2 self.assert_(calc_min < psi_uptime < calc_max, "%s < %s < %s" % (calc_min, psi_uptime, calc_max))
def check_psi(): psi.loadavg() psi.boottime() psi.uptime()
def test_lt_now(self): bt = psi.boottime() now = time.time() self.assert_(bt.timestamp() < now, '%s < %s' % (bt.timestamp(), now))
def test_gt_epoch(self): bt = psi.boottime() self.assert_(bt.timestamp() > 0, '%s > 0' % bt.timestamp())
def test_timespec(self): self.assert_(isinstance(psi.boottime(), psi.TimeSpec))