Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/tools/sumolib/miscutils/runner.py
428384 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2016-2026 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file runner.py
15
# @author Michael Behrisch
16
# @date 2019-01-09
17
18
from __future__ import absolute_import
19
from __future__ import print_function
20
21
import sys
22
import os
23
import unittest
24
25
# Do not use SUMO_HOME here to ensure you are always testing the
26
# functions from the same tree the test is in
27
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools'))
28
29
from sumolib import miscutils # noqa
30
31
32
class Test_Init(unittest.TestCase):
33
34
def test_parseTime(self):
35
self.assertEqual(42, miscutils.parseTime('00:00:42'))
36
self.assertEqual(3661, miscutils.parseTime('01:01:01'))
37
self.assertEqual(25 * 3600 + 61, miscutils.parseTime('1:1:1:1'))
38
self.assertEqual(-1, miscutils.parseTime('-00:00:01'))
39
40
def test_humanReadableTime(self):
41
hrt = miscutils.humanReadableTime
42
self.assertEqual(hrt(42), '00:00:42')
43
self.assertEqual(hrt(3661), '01:01:01')
44
self.assertEqual(hrt(25 * 3600 + 61), '1:01:01:01')
45
self.assertEqual(hrt(-1), '-00:00:01')
46
47
48
if __name__ == '__main__':
49
unittest.main()
50
51