Signed-off-by: YAMAMOTO Takashi <[email protected]> --- ryu/tests/unit/lib/test_hub.py | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ryu/tests/unit/lib/test_hub.py
diff --git a/ryu/tests/unit/lib/test_hub.py b/ryu/tests/unit/lib/test_hub.py new file mode 100644 index 0000000..02cccfb --- /dev/null +++ b/ryu/tests/unit/lib/test_hub.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import time +import unittest +from nose.tools import raises + +from ryu.lib import hub +hub.patch() + + +class MyException(BaseException): + pass + + +class Test_hub(unittest.TestCase): + """ Test case for ryu.lib.hub + """ + + def setUp(self): + pass + + def tearDown(self): + pass + + @raises(hub.Timeout) + def test_timeout1(self): + with hub.Timeout(0.1): + hub.sleep(1) + + @raises(MyException) + def test_timeout2(self): + with hub.Timeout(0.1, MyException): + hub.sleep(1) + + def test_timeout3(self): + with hub.Timeout(1): + hub.sleep(0.1) + # sleep some more to ensure timer cancelation + hub.sleep(2) -- 1.8.0.1 ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
