Skip to content

Commit 0dbf95a

Browse files
committed
Add test for _load_runtime_context
1 parent 752eb21 commit 0dbf95a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

opentelemetry-api/tests/context/test_context.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,17 @@ def test_set_current(self):
7474

7575
context.detach(token)
7676
self.assertEqual("yyy", context.get_value("a"))
77+
78+
class TestInitContext(unittest.TestCase):
79+
def test_load_runtime_context(self):
80+
from os import environ
81+
from opentelemetry.environment_variables import OTEL_PYTHON_CONTEXT
82+
from opentelemetry.context.contextvars_context import ContextVarsRuntimeContext
83+
84+
environ[OTEL_PYTHON_CONTEXT] = "contextvars_context"
85+
ctx = context._load_runtime_context()
86+
self.assertIsInstance(ctx, ContextVarsRuntimeContext)
87+
88+
environ.pop(OTEL_PYTHON_CONTEXT)
89+
ctx = context._load_runtime_context()
90+
self.assertIsInstance(ctx, ContextVarsRuntimeContext)

0 commit comments

Comments
 (0)