8000 Fix test for checking exception types against System.Object. · pythonnet/pythonnet@6fd91b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6fd91b2

Browse files
committed
Fix test for checking exception types against System.Object.
1 parent 392c08b commit 6fd91b2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/tests/test_exceptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,20 @@ def testExceptionIsInstanceOfSystemObject(self):
348348
# without causing a crash in the CPython interpreter). This test is
349349
# here mainly to remind me to update the caveat in the documentation
350350
# one day when when exceptions can be new-style classes.
351+
352+
# This behaviour is now over-shadowed by the implementation of
353+
# __instancecheck__ (i.e., overloading isinstance), so for all Python
354+
# version >= 2.6 we expect isinstance(<managed exception>, Object) to
355+
# be true, even though it does not really subclass Object.
351356
from System import OverflowException
352357
from System import Object
353358

354359
o = OverflowException('error')
355-
self.assertFalse(isinstance(o, Object))
356-
360+
361+
if sys.version_info >= (2, 6):
362+
self.assertTrue(isinstance(o, Object))
363+
else:
364+
self.assertFalse(isinstance(o, Object))
357365

358366

359367
def test_suite():

0 commit comments

Comments
 (0)
0