PROTON-997: Add Handler derivation tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/12482000 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/12482000 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/12482000 Branch: refs/heads/proton-go Commit: 12482000da9127c8ec5846586125dac1b2aff591 Parents: b430410 Author: Bozo Dragojevic <[email protected]> Authored: Tue Jul 21 14:02:09 2015 +0200 Committer: Bozo Dragojevic <[email protected]> Committed: Wed Sep 16 15:40:05 2015 +0200 ---------------------------------------------------------------------- tests/python/proton_tests/reactor.py | 68 ++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12482000/tests/python/proton_tests/reactor.py ---------------------------------------------------------------------- diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py index 36dc4ca..e2e8850 100644 --- a/tests/python/proton_tests/reactor.py +++ b/tests/python/proton_tests/reactor.py @@ -20,6 +20,7 @@ from __future__ import absolute_import from .common import Test from proton.reactor import Reactor +from proton.handlers import CHandshaker class Barf(Exception): pass @@ -47,7 +48,11 @@ class BarfOnFinal: def on_reactor_final(self, event): raise Barf() - + +class BarfOnFinalDerived(CHandshaker): + def on_reactor_final(self, event): + raise Barf() + class ExceptionTest(Test): def setUp(self): @@ -248,3 +253,64 @@ class ExceptionTest(Test): assert not barfs, "expected all barfs to be discarded" except Barf: assert False, "expected barf to be cancelled" + + +class HandlerDerivationTest(Test): + def setUp(self): + self.reactor = Reactor() + + def test_reactor_final_derived(self): + h = BarfOnFinalDerived() + self.reactor.global_handler = h + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + + def test_reactor_final_py_child_py(self): + class APoorExcuseForAHandler: + def __init__(self): + self.handlers = [BarfOnFinal()] + self.reactor.global_handler = APoorExcuseForAHandler() + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + + def test_reactor_final_py_child_derived(self): + class APoorExcuseForAHandler: + def __init__(self): + self.handlers = [BarfOnFinalDerived()] + self.reactor.global_handler = APoorExcuseForAHandler() + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + + def test_reactor_final_derived_child_derived(self): + class APoorExcuseForAHandler(CHandshaker): + def __init__(self): + CHandshaker.__init__(self) + self.handlers = [BarfOnFinalDerived()] + self.reactor.global_handler = APoorExcuseForAHandler() + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + + def test_reactor_final_derived_child_py(self): + class APoorExcuseForAHandler(CHandshaker): + def __init__(self): + CHandshaker.__init__(self) + self.handlers = [BarfOnFinal()] + self.reactor.global_handler = APoorExcuseForAHandler() + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
