@@ -16,6 +16,8 @@ class QCTests
1616 private static dynamic withArgs_PythonSuperInitDefault ;
1717 private static dynamic withArgs_PythonSuperInitInt ;
1818
19+ private static dynamic pureCSharpConstruction ;
20+
1921 private static dynamic containsTest ;
2022 private static dynamic module ;
2123 private static string testModule = @"
@@ -63,6 +65,9 @@ def __init__(self):
6365class PythonSuperInitNone(SuperInit):
6466 def jose(self):
6567 return 1
68+
69+ def PureCSharpConstruction():
70+ return SuperInit(1)
6671" ;
6772
6873 [ OneTimeSetUp ]
@@ -81,6 +86,8 @@ public void Setup()
8186 withArgs_PythonSuperInitNotCallingBase = pyModule . GetAttr ( "WithArgs_PythonSuperInitNotCallingBase" ) ;
8287 withArgs_PythonSuperInitDefault = pyModule . GetAttr ( "WithArgs_PythonSuperInitDefault" ) ;
8388 withArgs_PythonSuperInitInt = pyModule . GetAttr ( "WithArgs_PythonSuperInitInt" ) ;
89+
90+ pureCSharpConstruction = pyModule . GetAttr ( "PureCSharpConstruction" ) ;
8491 }
8592
8693 [ OneTimeTearDown ]
@@ -107,15 +114,26 @@ public void ContainsTest(string key, bool expected)
107114 Assert . AreEqual ( expected , ( bool ) containsTest ( key , dic ) ) ;
108115 }
109116
117+ [ Test ]
118+ public void PureCSharpConstruction ( )
119+ {
120+ using ( Py . GIL ( ) )
121+ {
122+ var instance = pureCSharpConstruction ( ) ;
123+ Assert . AreEqual ( 1 , ( int ) instance . CalledInt ) ;
124+ Assert . AreEqual ( 1 , ( int ) instance . CalledDefault ) ;
125+ }
126+ }
127+
110128 [ Test ]
111129 public void WithArgs_NoBaseConstructorCall ( )
112130 {
113131 using ( Py . GIL ( ) )
114132 {
115133 var instance = withArgs_PythonSuperInitNotCallingBase ( 1 ) ;
116- // this is true because we call the constructor always
117- Assert . IsTrue ( ( bool ) instance . CalledInt ) ;
118- Assert . IsFalse ( ( bool ) instance . CalledDefault ) ;
134+ Assert . AreEqual ( 0 , ( int ) instance . CalledInt ) ;
135+ // we call the constructor always
136+ Assert . AreEqual ( 1 , ( int ) instance . CalledDefault ) ;
119137 }
120138 }
121139
@@ -125,8 +143,8 @@ public void WithArgs_IntConstructor()
125143 using ( Py . GIL ( ) )
126144 {
127145 var instance = withArgs_PythonSuperInitInt ( 1 ) ;
128- Assert . IsTrue ( ( bool ) instance . CalledInt ) ;
129- Assert . IsFalse ( ( bool ) instance . CalledDefault ) ;
146+ Assert . AreEqual ( 1 , ( int ) instance . CalledInt ) ;
147+ Assert . AreEqual ( 1 , ( int ) instance . CalledDefault ) ;
130148 }
131149 }
132150
@@ -136,8 +154,8 @@ public void WithArgs_DefaultConstructor()
136154 using ( Py . GIL ( ) )
137155 {
138156 var instance = withArgs_PythonSuperInitDefault ( 1 ) ;
139- Assert . IsTrue ( ( bool ) instance . CalledInt ) ;
140- Assert . IsTrue ( ( bool ) instance . CalledDefault ) ;
157+ Assert . AreEqual ( 0 , ( int ) instance . CalledInt ) ;
158+ Assert . AreEqual ( 2 , ( int ) instance . CalledDefault ) ;
141159 }
142160 }
143161
@@ -147,9 +165,9 @@ public void NoArgs_NoBaseConstructorCall()
147165 using ( Py . GIL ( ) )
148166 {
149167 var instance = pythonSuperInitNotCallingBase ( ) ;
150- Assert . IsFalse ( ( bool ) instance . CalledInt ) ;
168+ Assert . AreEqual ( 0 , ( int ) instance . CalledInt ) ;
151169 // this is true because we call the default constructor always
152- Assert . IsTrue ( ( bool ) instance . CalledDefault ) ;
170+ Assert . AreEqual ( 1 , ( int ) instance . CalledDefault ) ;
153171 }
154172 }
155173
@@ -159,9 +177,9 @@ public void NoArgs_IntConstructor()
159177 using ( Py . GIL ( ) )
160178 {
161179 var instance = pythonSuperInitInt ( ) ;
162- Assert . IsTrue ( ( bool ) instance . CalledInt ) ;
180+ Assert . AreEqual ( 1 , ( int ) instance . CalledInt ) ;
163181 // this is true because we call the default constructor always
164- Assert . IsTrue ( ( bool ) instance . CalledDefault ) ;
182+ Assert . AreEqual ( 1 , ( int ) instance . CalledDefault ) ;
165183 }
166184 }
167185
@@ -171,8 +189,8 @@ public void NoArgs_DefaultConstructor()
171189 using ( Py . GIL ( ) )
172190 {
173191 var instance = pythonSuperInitNone ( ) ;
174- Assert . IsFalse ( ( bool ) instance . CalledInt ) ;
175- Assert . IsTrue ( ( bool ) instance . CalledDefault ) ;
192+ Assert . AreEqual ( 0 , ( int ) instance . CalledInt ) ;
193+ Assert . AreEqual ( 2 , ( int ) instance . CalledDefault ) ;
176194 }
177195 }
178196
@@ -183,8 +201,8 @@ public void NoArgs_NoConstructor()
183201 {
184202 var instance = pythonSuperInitDefault . Invoke ( ) ;
185203
186- Assert . IsFalse ( ( bool ) instance . CalledInt ) ;
187- Assert . IsTrue ( ( bool ) instance . CalledDefault ) ;
204+ Assert . AreEqual ( 0 , ( int ) instance . CalledInt ) ;
205+ Assert . AreEqual ( 2 , ( int ) instance . CalledDefault ) ;
188206 }
189207 }
190208 }
@@ -210,15 +228,15 @@ public void EmitInsights(params Insight[] insights)
210228
211229 public class SuperInit
212230 {
213- public bool CalledInt { get ; private set ; }
214- public bool CalledDefault { get ; private set ; }
231+ public int CalledInt { get ; private set ; }
232+ public int CalledDefault { get ; private set ; }
215233 public SuperInit ( int a )
216234 {
217- CalledInt = true ;
235+ CalledInt ++ ;
218236 }
219237 public SuperInit ( )
220238 {
221- CalledDefault = true ;
239+ CalledDefault ++ ;
222240 }
223241 }
224242
0 commit comments