Skip to content

Commit 14ad114

Browse files
WIP
1 parent 015b1db commit 14ad114

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

test/test_typehints.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def setup_class(cls):
4444
float callme(std::string a, bool b, std::vector<int> c) { return 0.0f; }
4545
template <typename T>
4646
T callme(T v) { return v; }
47+
template <typename T>
48+
static T s_callme(T v) { return v; }
4749
};
4850
float callme(std::string a, bool b, std::vector<int> c) { return 0.0f; }
4951
template <typename T>
@@ -57,40 +59,40 @@ def test_invalids(self):
5759
from cppyy import gbl, generate_typehints
5860

5961
typehint = generate_typehints("x")
60-
assert "x: int\n" == typehint
62+
assert typehint.startswith("x: int\n")
6163
typehint = generate_typehints("y")
62-
assert "y: float\n" == typehint
64+
assert typehint.startswith("y: float\n")
6365
typehint = generate_typehints("z")
64-
assert "z: int\n" == typehint
66+
assert typehint.startswith("z: int\n")
6567
typehint = generate_typehints("a")
66-
assert "a: str\n" == typehint
68+
assert typehint.startswith("a: str\n")
6769
typehint = generate_typehints("sa")
68-
assert "sa: int\n" == typehint
70+
assert typehint.startswith("sa: int\n")
6971
typehint = generate_typehints("usa")
70-
assert "usa: int\n" == typehint
72+
assert typehint.startswith("usa: int\n")
7173

72-
with raises(NotImplementedError) as err:
73-
generate_typehints("MyKlass")
74-
assert "class" in str(err)
74+
typehint = generate_typehints("MyKlass")
75+
assert "class MyKlass" in typehint
7576

7677
typehint = generate_typehints("callme")
7778
assert (
78-
'@overload\ndef callme (a: "std.string", b: bool, c: "std.vector[int]") -> float: ...\n'
79-
== typehint
79+
'@overload\ndef callme(a: "std.string", b: bool, c: "std.vector[int]") -> float:\n'
80+
in typehint
8081
)
8182

8283
typehint = generate_typehints("Klass")
83-
assert "Klass = MyKlass\n" == typehint
84+
assert typehint.startswith("Klass = MyKlass\n")
8485

8586
typehint = generate_typehints("KlassFloat")
86-
assert "KlassFloat = \"MyTKlass[float]\"\n" == typehint
87+
assert typehint.startswith("KlassFloat = \"MyTKlass[float]\"\n")
8788

88-
with raises(NotImplementedError) as err:
89-
generate_typehints("MyTKlass")
89+
typehint = generate_typehints("MyTKlass")
90+
assert "class MyTKlass[T]:" in typehint
91+
assert "obj: T" in typehint
9092

91-
with raises(NotImplementedError) as err:
92-
generate_typehints("TypeHints")
93-
assert "namespace" in str(err)
93+
94+
typehint = generate_typehints("TypeHints")
95+
assert "class TypeHints:" in typehint
9496

9597
with raises(TypeError) as err:
9698
generate_typehints("unknown")

0 commit comments

Comments
 (0)