def _initUI(self): # Widgets self._txt_time = QLineEdit() self._txt_time.setText(human_time(self.result().simulation_time_s)) self._txt_time.setReadOnly(True) self._txt_speed = QLineEdit() self._txt_speed.setText(human_time(self.result().simulation_speed_s[0])) self._txt_speed.setReadOnly(True) # Layouts layout = _SaveableResultWidget._initUI(self) sublayout = QFormLayout() if sys.platform == "darwin": # Fix for Mac OS layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) sublayout.addRow("Total time of the simulation", self._txt_time) sublayout.addRow("Average time of one trajectory", self._txt_speed) layout.addLayout(sublayout) layout.addStretch() return layout
def test_human_time(time_s, expected): assert human_time(time_s) == expected
def testhuman_time(self): self.assertEqual('5 sec', human_time(5)) self.assertEqual('1 min 5 sec', human_time(65)) self.assertEqual('1 min', human_time(60)) self.assertEqual('1 hr 1 min 5 sec', human_time(3665)) self.assertEqual('1 hr 1 min', human_time(3660)) self.assertEqual('1 hr 5 sec', human_time(3605)) self.assertEqual('1 hr', human_time(3600)) self.assertEqual('1 day', human_time(86400)) self.assertEqual('2 days', human_time(172800)) self.assertEqual('1 day 1 hr', human_time(90000)) self.assertEqual('1 day 1 hr 1 min', human_time(90060)) self.assertEqual('1 day 1 hr 1 min 1 sec', human_time(90061))