Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-160-Operation-toolbelt-unit-tests-fail-spordically 5440f7540 -> 179a2279d (forced update)
moved to class based threadlocal Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/179a2279 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/179a2279 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/179a2279 Branch: refs/heads/ARIA-160-Operation-toolbelt-unit-tests-fail-spordically Commit: 179a2279d51c3609ea76836979f55a962e6569c3 Parents: 788cfd9 Author: max-orlov <[email protected]> Authored: Sun May 7 10:46:20 2017 +0300 Committer: max-orlov <[email protected]> Committed: Sun May 7 10:52:25 2017 +0300 ---------------------------------------------------------------------- tests/helpers.py | 25 ++++++++++++++++---- tests/orchestrator/context/test_operation.py | 2 +- tests/orchestrator/context/test_toolbelt.py | 4 +--- .../orchestrator/workflows/core/test_engine.py | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/179a2279/tests/helpers.py ---------------------------------------------------------------------- diff --git a/tests/helpers.py b/tests/helpers.py index 6c9712b..329b848 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -32,8 +32,25 @@ def get_service_template_uri(*args): return os.path.join(RESOURCES_DIR, 'service-templates', *args) -def create_global_test_holder(): - thread_local = local() - thread_local.holder = {} - return thread_local.holder +class GlobalTestHolder(local): + def __init__(self): + super(GlobalTestHolder, self).__init__() + self._holder = {} + def __setitem__(self, key, value): + self._holder[key] = value + + def __getitem__(self, item): + return self._holder[item] + + def clear(self): + self._holder.clear() + + def __iter__(self): + return iter(self._holder) + + def get(self, item, default=None): + return self._holder.get(item, default) + + def setdefault(self, key, value): + return self._holder.setdefault(key, value) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/179a2279/tests/orchestrator/context/test_operation.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index 5112179..d351846 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -38,7 +38,7 @@ from . import ( execute, ) -global_test_holder = helpers.create_global_test_holder() +global_test_holder = helpers.GlobalTestHolder() @pytest.fixture def ctx(tmpdir): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/179a2279/tests/orchestrator/context/test_toolbelt.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py index 3675c16..5a319cc 100644 --- a/tests/orchestrator/context/test_toolbelt.py +++ b/tests/orchestrator/context/test_toolbelt.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from threading import local - import pytest from aria import workflow, operation @@ -33,7 +31,7 @@ from . import ( execute, ) -global_test_holder = helpers.create_global_test_holder() +global_test_holder = helpers.GlobalTestHolder() @pytest.fixture http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/179a2279/tests/orchestrator/workflows/core/test_engine.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py index 8c0705b..c4334e1 100644 --- a/tests/orchestrator/workflows/core/test_engine.py +++ b/tests/orchestrator/workflows/core/test_engine.py @@ -31,10 +31,10 @@ from aria.orchestrator.workflows import ( from aria.orchestrator.workflows.core import engine from aria.orchestrator.workflows.executor import thread -from tests import mock, storage +from tests import mock, storage, helpers -global_test_holder = {} +global_test_holder = helpers.GlobalTestHolder() class BaseTest(object):
