Skip to content

Commit 6dfb30f

Browse files
authored
Merge pull request #252 from toruseo/type
Add basic type hint
2 parents 2bc3c7f + e070af0 commit 6dfb30f

File tree

3 files changed

+163
-147
lines changed

3 files changed

+163
-147
lines changed

.github/workflows/verify-module.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
# Install testing dependencies with compatible versions for parallel execution
2626
pip install "pytest>=8.4.0" "pytest-xdist>=3.8.0" "pytest-rerunfailures>=16.0" setuptools
2727
- name: Run verifications with pytest
28-
run: pytest -n auto tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py tests/test_verification_sioux_falls.py tests/test_verification_multilane.py tests/test_verification_taxi.py tests/test_verification_dta_solvers.py --durations=0 -v
28+
run: pytest -n auto tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py tests/test_verification_sioux_falls.py tests/test_verification_multilane.py tests/test_verification_taxi.py tests/test_verification_dta_solvers.py tests/test_wrapper_functions.py --durations=0 -v

tests/test_wrapper_functions.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
This script tests the consistency between wrapper functions and their original in UXsim.
3+
"""
4+
5+
import pytest
6+
import inspect
7+
8+
import uxsim
9+
10+
def arg_compare_wrapper(orig, wrapper):
11+
sig_original = inspect.signature(orig)
12+
sig_wrapper = inspect.signature(wrapper)
13+
14+
params_original = list(sig_original.parameters.values())[2:]
15+
params_wrapper = list(sig_wrapper.parameters.values())[1:]
16+
17+
assert len(params_original) == len(params_wrapper), "Number of args differ"
18+
19+
for po, pw in zip(params_original, params_wrapper):
20+
print("checking:", po, "and", pw, end=" ... ")
21+
assert po.name == pw.name, f"Arg name mismatch: {po.name} != {pw.name}"
22+
assert po.default == pw.default, f"Default mismatch for {po.name}"
23+
assert po.kind == pw.kind, f"Kind mismatch for {po.name}"
24+
print("OK")
25+
26+
return True
27+
28+
def test_addNode():
29+
assert arg_compare_wrapper(uxsim.Node.__init__, uxsim.World.addNode)
30+
31+
def test_addLink():
32+
assert arg_compare_wrapper(uxsim.Link.__init__, uxsim.World.addLink)
33+
34+
def test_defRoute():
35+
assert arg_compare_wrapper(uxsim.Route.__init__, uxsim.World.defRoute)

0 commit comments

Comments
 (0)