Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/tools/sumolib/init/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
import sumolib # noqa
30
31
32
class Test_Init(unittest.TestCase):
33
34
def test_checkBinary(self):
35
self.assertEqual(os.environ['SUMO_BINARY'], sumolib.checkBinary('sumo'))
36
del os.environ['SUMO_BINARY']
37
self.assertIn('sumo', sumolib.checkBinary('sumo'))
38
del os.environ['SUMO_HOME']
39
try:
40
# try whether the eclipse-sumo wheel is installed
41
import sumo # noqa
42
self.assertIn('sumo', sumolib.checkBinary('sumo'))
43
self.assertIn('python', sumolib.checkBinary('sumo').lower())
44
except ImportError:
45
self.assertEqual('sumo', sumolib.checkBinary('sumo', ''))
46
47
def test_intTime(self):
48
self.assertEqual(1, sumolib._intTime('1.0'))
49
self.assertEqual(1, sumolib._intTime('1.1'))
50
self.assertEqual(1, sumolib._intTime('1.9'))
51
52
53
if __name__ == '__main__':
54
unittest.main()
55
56