qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject [qpid-proton] 05/06: PROTON-1992: [Python] Give on_timer_task event a valid container - Fixes a problem with dispatch unit tests
Date Mon, 25 Feb 2019 18:40:22 GMT
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 46979cfe2872eb2bc7f48a2d8ff5a9ee4a4b414e
Author: Andrew Stitcher <astitcher@apache.org>
AuthorDate: Wed Jan 23 00:13:02 2019 -0500

    PROTON-1992: [Python] Give on_timer_task event a valid container
    - Fixes a problem with dispatch unit tests
---
 python/proton/_reactor.py            |  8 ++++++--
 python/tests/proton_tests/reactor.py | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/python/proton/_reactor.py b/python/proton/_reactor.py
index 6cf5305..993c177 100644
--- a/python/proton/_reactor.py
+++ b/python/proton/_reactor.py
@@ -19,7 +19,7 @@
 
 from __future__ import absolute_import
 
-from functools import total_ordering
+#from functools import total_ordering
 import heapq
 import json
 import logging
@@ -59,7 +59,7 @@ def _generate_uuid():
 def _now():
     return time.time()
 
-@total_ordering
+#@total_ordering
 class Task(object):
 
     def __init__(self, reactor, deadline, handler):
@@ -78,6 +78,10 @@ class Task(object):
     def handler(self):
         return self._handler
 
+    @property
+    def container(self):
+        return self._reactor
+
 class TimerSelectable(Selectable):
 
     def __init__(self, reactor, collector):
diff --git a/python/tests/proton_tests/reactor.py b/python/tests/proton_tests/reactor.py
index 923af2d..0e80e49 100644
--- a/python/tests/proton_tests/reactor.py
+++ b/python/tests/proton_tests/reactor.py
@@ -191,6 +191,20 @@ class ExceptionTest(Test):
         except Barf:
             pass
 
+    def test_schedule_event(self):
+        class Nothing:
+            def __init__(self, p):
+                self.parent = p
+
+            results = []
+            def on_timer_task(self, event):
+                self.parent.triggered = True
+                assert event.context == self.parent.task
+                assert event.container == self.parent.container
+        self.task = self.container.schedule(0, Nothing(self))
+        self.container.run()
+        assert self.triggered == True
+
     def test_schedule_many_nothings(self):
         class Nothing:
             results = []


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message