diff options
author | Kali Kaneko <kali@leap.se> | 2015-07-13 11:48:47 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-07-21 13:26:57 -0400 |
commit | 467b14fa2e29ecd6f41d4834b00593d8c86cddc5 (patch) | |
tree | 90a55edfd571974bdb68ec4e65b5c068aa03dbcf /src/leap/common/testing | |
parent | 87339921eac261954e39901e3563851830309cc5 (diff) |
[feature] add global flag for disabling the events framework
this will be used to allow the unittests to disable the events
framework. this way, emit() will become a passthrough.
note that, until now, the basetest class is making use of the threaded
version of the client, which launches a zmq tornado-based ioloop. this
is wrong, and will have to be addressed in a future commit. we'll have
to make use of the global EVENTS_ENABLED flag in the txclient version
when those changes are made.
Related: #7259
Relases: 0.4.2
Diffstat (limited to 'src/leap/common/testing')
-rw-r--r-- | src/leap/common/testing/basetest.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/leap/common/testing/basetest.py b/src/leap/common/testing/basetest.py index 3fbcf33..3d3cee0 100644 --- a/src/leap/common/testing/basetest.py +++ b/src/leap/common/testing/basetest.py @@ -30,8 +30,11 @@ except ImportError: from leap.common.check import leap_assert from leap.common.events import server as events_server from leap.common.events import client as events_client +from leap.common.events import flags, set_events_enabled from leap.common.files import mkdir_p, check_and_fix_urw_only +set_events_enabled(False) + class BaseLeapTest(unittest.TestCase): """ @@ -73,12 +76,13 @@ class BaseLeapTest(unittest.TestCase): @classmethod def _init_events(cls): - cls._server = events_server.ensure_server( - emit_addr="tcp://127.0.0.1:0", - reg_addr="tcp://127.0.0.1:0") - events_client.configure_client( - emit_addr="tcp://127.0.0.1:%d" % cls._server.pull_port, - reg_addr="tcp://127.0.0.1:%d" % cls._server.pub_port) + if flags.EVENTS_ENABLED: + cls._server = events_server.ensure_server( + emit_addr="tcp://127.0.0.1:0", + reg_addr="tcp://127.0.0.1:0") + events_client.configure_client( + emit_addr="tcp://127.0.0.1:%d" % cls._server.pull_port, + reg_addr="tcp://127.0.0.1:%d" % cls._server.pub_port) @classmethod def tearDownEnv(cls): @@ -87,8 +91,9 @@ class BaseLeapTest(unittest.TestCase): - restores the default PATH and HOME variables - removes the temporal folder """ - events_client.shutdown() - cls._server.shutdown() + if flags.EVENTS_ENABLED: + events_client.shutdown() + cls._server.shutdown() os.environ["PATH"] = cls.old_path os.environ["HOME"] = cls.old_home |