Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9cad61a

Browse files
author
Chris Rossi
authored
test: refactor concurrency test using orchestrate (#709)
Towards #691
1 parent ede0f7c commit 9cad61a

File tree

5 files changed

+882
-128
lines changed

5 files changed

+882
-128
lines changed

packages/google-cloud-ndb/google/cloud/ndb/_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ def _update_key(key, new_value):
683683
utils.logging_debug(log, "old value: {}", old_value)
684684

685685
value = new_value(old_value)
686-
utils.logging_debug(log, "new value: {}", value)
686+
utils.logging_debug(log, "new value: {}", value) # pragma: SYNCPOINT update key
687687

688688
if old_value is not None:
689689
utils.logging_debug(log, "compare and swap")

packages/google-cloud-ndb/tests/conftest.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,31 @@ def initialize_environment(request, environ):
8888

8989

9090
@pytest.fixture
91-
def context():
92-
client = mock.Mock(
93-
project="testing",
94-
namespace=None,
95-
spec=("project", "namespace"),
96-
stub=mock.Mock(spec=()),
97-
)
98-
context = context_module.Context(
99-
client,
100-
eventloop=TestingEventLoop(),
101-
datastore_policy=True,
102-
legacy_data=False,
103-
)
91+
def context_factory():
92+
def context(**kwargs):
93+
client = mock.Mock(
94+
project="testing",
95+
namespace=None,
96+
spec=("project", "namespace"),
97+
stub=mock.Mock(spec=()),
98+
)
99+
context = context_module.Context(
100+
client,
101+
eventloop=TestingEventLoop(),
102+
datastore_policy=True,
103+
legacy_data=False,
104+
**kwargs
105+
)
106+
return context
107+
104108
return context
105109

106110

111+
@pytest.fixture
112+
def context(context_factory):
113+
return context_factory()
114+
115+
107116
@pytest.fixture
108117
def in_context(context):
109118
assert not context_module._state.context

0 commit comments

Comments
 (0)