diff options
Diffstat (limited to 'tests/test_gi.py')
-rw-r--r-- | tests/test_gi.py | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/tests/test_gi.py b/tests/test_gi.py index 4545539..e51d7cf 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -12,6 +12,7 @@ import locale import subprocess import gc import weakref +import warnings from io import StringIO, BytesIO import gi @@ -1350,13 +1351,15 @@ class TestGValue(unittest.TestCase): class TestGClosure(unittest.TestCase): - def test_gclosure_in(self): + def test_in(self): GIMarshallingTests.gclosure_in(lambda: 42) + def test_pass(self): # test passing a closure between two C calls closure = GIMarshallingTests.gclosure_return() GIMarshallingTests.gclosure_in(closure) + def test_type_error(self): self.assertRaises(TypeError, GIMarshallingTests.gclosure_in, 42) self.assertRaises(TypeError, GIMarshallingTests.gclosure_in, None) @@ -2227,21 +2230,8 @@ class TestMultiOutputArgs(unittest.TestCase): self.assertEqual((6, 7), GIMarshallingTests.int_return_out()) -class TestGErrorException(unittest.TestCase): - def test_gerror_exception(self): - self.assertRaises(GObject.GError, GIMarshallingTests.gerror) - try: - GIMarshallingTests.gerror() - except Exception: - etype, e = sys.exc_info()[:2] - self.assertEqual(e.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN) - self.assertEqual(e.code, GIMarshallingTests.CONSTANT_GERROR_CODE) - self.assertEqual(e.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE) - - # Interface - class TestInterfaces(unittest.TestCase): class TestInterfaceImpl(GObject.GObject, GIMarshallingTests.Interface): @@ -2451,19 +2441,17 @@ class TestDir(unittest.TestCase): # self.assertTrue('DoNotImportDummyTests' in list) -class TestGErrorArrayInCrash(unittest.TestCase): - # Previously there was a bug in invoke, in which C arrays were unwrapped - # from inside GArrays to be passed to the C function. But when a GError was - # set, invoke would attempt to free the C array as if it were a GArray. - # This crash is only for C arrays. It does not happen for C functions which - # take in GArrays. See https://bugzilla.gnome.org/show_bug.cgi?id=642708 - def test_gerror_array_in_crash(self): +class TestGError(unittest.TestCase): + def test_array_in_crash(self): + # Previously there was a bug in invoke, in which C arrays were unwrapped + # from inside GArrays to be passed to the C function. But when a GError was + # set, invoke would attempt to free the C array as if it were a GArray. + # This crash is only for C arrays. It does not happen for C functions which + # take in GArrays. See https://bugzilla.gnome.org/show_bug.cgi?id=642708 self.assertRaises(GObject.GError, GIMarshallingTests.gerror_array_in, [1, 2, 3]) - -class TestGErrorOut(unittest.TestCase): - # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 - def test_gerror_out(self): + def test_out(self): + # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 error, debug = GIMarshallingTests.gerror_out() self.assertIsInstance(error, GObject.GError) @@ -2472,10 +2460,8 @@ class TestGErrorOut(unittest.TestCase): self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE) self.assertEqual(debug, GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE) - -class TestGErrorOutTransferNone(unittest.TestCase): - # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 - def test_gerror_out_transfer_none(self): + def test_out_transfer_none(self): + # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 error, debug = GIMarshallingTests.gerror_out_transfer_none() self.assertIsInstance(error, GObject.GError) @@ -2484,10 +2470,8 @@ class TestGErrorOutTransferNone(unittest.TestCase): self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE) self.assertEqual(GIMarshallingTests.CONSTANT_GERROR_DEBUG_MESSAGE, debug) - -class TestGErrorReturn(unittest.TestCase): - # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 - def test_return_gerror(self): + def test_return(self): + # See https://bugzilla.gnome.org/show_bug.cgi?id=666098 error = GIMarshallingTests.gerror_return() self.assertIsInstance(error, GObject.GError) @@ -2495,6 +2479,16 @@ class TestGErrorReturn(unittest.TestCase): self.assertEqual(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE) self.assertEqual(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE) + def test_exception(self): + self.assertRaises(GObject.GError, GIMarshallingTests.gerror) + try: + GIMarshallingTests.gerror() + except Exception: + etype, e = sys.exc_info()[:2] + self.assertEqual(e.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN) + self.assertEqual(e.code, GIMarshallingTests.CONSTANT_GERROR_CODE) + self.assertEqual(e.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE) + class TestParamSpec(unittest.TestCase): # https://bugzilla.gnome.org/show_bug.cgi?id=682355 @@ -2907,3 +2901,12 @@ class TestSignatureArgs(unittest.TestCase): def test_overridden_doc_is_not_clobbered(self): self.assertEqual(GIMarshallingTests.OverridesObject.method.__doc__, 'Overridden doc string.') + + +class TestDeprecation(unittest.TestCase): + def test_method(self): + d = GLib.Date.new() + with warnings.catch_warnings(record=True) as warn: + warnings.simplefilter('always') + d.set_time(1) + self.assertTrue(issubclass(warn[0].category, DeprecationWarning)) |