[pygobject] Mark GLib.Source.get_current_time() as deprecated



commit f30efd2619911c89ca873fac6bec06a1b60fab82
Author: Martin Pitt <martinpitt gnome org>
Date:   Tue Oct 23 13:32:14 2012 +0200

    Mark GLib.Source.get_current_time() as deprecated
    
    This method has been deprecated in GLib long ago. We have a workaround
    implementation using GLib.get_real_time(), but eventually this should go away.

 gi/overrides/GLib.py |    5 ++++-
 tests/test_source.py |    8 +++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 0969cf0..9deb651 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -23,7 +23,7 @@ import signal
 
 from ..importer import modules
 from .._gi import variant_new_tuple, variant_type_from_string, source_new, source_set_callback
-from ..overrides import override
+from ..overrides import override, deprecated
 
 GLib = modules['GLib']._introspection_module
 
@@ -489,6 +489,9 @@ class Source(GLib.Source):
     def get_current_time(self):
         return GLib.get_real_time() * 0.000001
 
+    get_current_time = deprecated(get_current_time,
+                                  'GLib.Source.get_time() or GLib.get_real_time()')
+
     # as get/set_priority are introspected, we can't use the static
     # property(get_priority, ..) here
     def __get_priority(self):
diff --git a/tests/test_source.py b/tests/test_source.py
index d77060f..82be8ce 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
 
 import unittest
+import warnings
 
 from gi.repository import GLib, GObject
 
@@ -156,8 +157,13 @@ class TestSource(unittest.TestCase):
         self.assertEqual(s.priority, GLib.PRIORITY_DEFAULT)
 
     def testGetCurrentTime(self):
+        # Note, deprecated API
         s = GLib.Idle()
-        time = s.get_current_time()
+        with warnings.catch_warnings(record=True) as w:
+            warnings.simplefilter('always')
+            time = s.get_current_time()
+            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
+
         self.assertTrue(isinstance(time, float))
         # plausibility check, and check magnitude of result
         self.assertGreater(time, 1300000000.0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]