Skip to content

Commit d3ab512

Browse files
Added UTCs
1 parent d8d7a15 commit d3ab512

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/test_run_config.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,55 @@ async def test_agent_model_object_is_used_when_present() -> None:
8686
# the FakeModel on the agent.
8787
assert provider.last_requested is None
8888
assert result.final_output == "from-agent-object"
89+
90+
91+
def test_trace_include_sensitive_data_defaults_to_true_when_env_not_set(monkeypatch):
92+
"""By default, trace_include_sensitive_data should be True when the env is not set."""
93+
monkeypatch.delenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", raising=False)
94+
config = RunConfig()
95+
assert config.trace_include_sensitive_data is True
96+
97+
98+
@pytest.mark.parametrize(
99+
"env_value,expected",
100+
[
101+
("true", True),
102+
("True", True),
103+
("1", True),
104+
("yes", True),
105+
("on", True),
106+
("false", False),
107+
("False", False),
108+
("0", False),
109+
("no", False),
110+
("off", False),
111+
],
112+
ids=[
113+
"lowercase-true",
114+
"capital-True",
115+
"numeric-1",
116+
"text-yes",
117+
"text-on",
118+
"lowercase-false",
119+
"capital-False",
120+
"numeric-0",
121+
"text-no",
122+
"text-off",
123+
],
124+
)
125+
def test_trace_include_sensitive_data_follows_env_value(env_value, expected, monkeypatch):
126+
"""trace_include_sensitive_data should follow the environment variable if not explicitly set."""
127+
monkeypatch.setenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", env_value)
128+
config = RunConfig()
129+
assert config.trace_include_sensitive_data is expected
130+
131+
132+
def test_trace_include_sensitive_data_explicit_override_takes_precedence(monkeypatch):
133+
"""Explicit value passed to RunConfig should take precedence over the environment variable."""
134+
monkeypatch.setenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", "false")
135+
config = RunConfig(trace_include_sensitive_data=True)
136+
assert config.trace_include_sensitive_data is True
137+
138+
monkeypatch.setenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", "true")
139+
config = RunConfig(trace_include_sensitive_data=False)
140+
assert config.trace_include_sensitive_data is False

0 commit comments

Comments
 (0)