Skip to content

Commit 45e3452

Browse files
committed
fixed unit test for truncated artifact content
1 parent 7bcbc5e commit 45e3452

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

tests/test_artifacts.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,30 +202,26 @@ def setUp(self):
202202
config = PromptConfig()
203203
self.sampler = PromptSampler(config)
204204

205-
def test_render_artifacts_prioritized(self):
206-
"""Test that stderr/stdout/traceback are prioritized"""
205+
def test_render_artifacts_all_items(self):
206+
"""Test that all artifacts are included using .items() without prioritization"""
207207
artifacts = {
208208
"stderr": "error message",
209-
"stdout": "output message",
209+
"stdout": "output message",
210210
"traceback": "stack trace",
211211
"other": "other data",
212212
}
213213

214214
rendered = self.sampler._render_artifacts(artifacts)
215215

216-
# Check that prioritized items come first
217-
lines = rendered.split("\n")
218-
stderr_idx = next(i for i, line in enumerate(lines) if "Stderr" in line)
219-
stdout_idx = next(i for i, line in enumerate(lines) if "Stdout" in line)
220-
traceback_idx = next(i for i, line in enumerate(lines) if "Traceback" in line)
221-
other_idx = next(i for i, line in enumerate(lines) if "other" in line)
222-
223-
# Prioritized items should come before others
224-
self.assertLess(stderr_idx, other_idx)
225-
self.assertLess(stdout_idx, other_idx)
226-
self.assertLess(traceback_idx, other_idx)
216+
# All artifacts should be present (no prioritization)
217+
for key in artifacts.keys():
218+
self.assertIn(key, rendered)
219+
220+
# Check that all content is included
221+
for value in artifacts.values():
222+
self.assertIn(value, rendered)
227223

228-
def test_render_artifacts_all_items(self):
224+
def test_render_artifacts_generic(self):
229225
"""Test that all artifacts are included using .items()"""
230226
artifacts = {"log1": "first log", "log2": "second log", "config": "configuration data"}
231227

@@ -237,16 +233,14 @@ def test_render_artifacts_all_items(self):
237233

238234
def test_render_artifacts_truncation(self):
239235
"""Test artifact truncation for large content"""
240-
# Create content that won't trigger security filter but will be truncated
241-
large_content = "This is a very long log message. " * 200 # Creates ~6.6KB of text
236+
# Create content larger than 20KB to trigger truncation
237+
large_content = "This is a very long log message. " * 700 # Creates ~23KB of text
242238
artifacts = {"large_log": large_content}
243239

244240
rendered = self.sampler._render_artifacts(artifacts)
245241

246-
# Should be truncated (check that it's shorter than original)
247-
self.assertLess(len(rendered), len(large_content))
248242
# Should contain truncation indicator
249-
self.assertTrue("(truncated)" in rendered or len(rendered) < len(large_content))
243+
self.assertIn("(truncated)", rendered)
250244

251245
def test_render_artifacts_security_filter(self):
252246
"""Test that security filter redacts potential tokens"""

0 commit comments

Comments
 (0)