MCPcopy Create free account
hub / github.com/hynek/structlog / test_is_thread_local

Method test_is_thread_local

tests/test_threadlocal.py:188–210  ·  view source on GitHub ↗

The context is *not* shared between threads.

(self, D)

Source from the content-addressed store, hash-verified

186 greenlet is not None, reason="Don't mix threads and greenlets."
187 )
188 def test_is_thread_local(self, D):
189 """
190 The context is *not* shared between threads.
191 """
192
193 class TestThread(threading.Thread):
194 def __init__(self, d):
195 self._d = d
196 threading.Thread.__init__(self)
197
198 def run(self):
199 assert "tl" not in self._d._dict
200
201 self._d["tl"] = 23
202
203 with pytest.deprecated_call():
204 d = wrap_dict(dict)()
205 d["tl"] = 42
206 t = TestThread(d)
207 t.start()
208 t.join()
209
210 assert 42 == d._dict["tl"]
211
212 def test_context_is_global_to_thread(self, D):
213 """

Callers

nothing calls this directly

Calls 2

wrap_dictFunction · 0.90
TestThreadClass · 0.85

Tested by

no test coverage detected