Skip to content

Commit 5ffd47d

Browse files
committed
Clean up test files
1 parent cd2173e commit 5ffd47d

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

src/guardrails/_base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _mask_text(text: str) -> str:
335335
len(candidate_lower) >= 3
336336
and any( # Any 3-char chunk overlaps
337337
candidate_lower[i : i + 3] in detected_lower
338-
for i in range(0, len(candidate_lower) - 2, 2) # Step by 2 for efficiency
338+
for i in range(len(candidate_lower) - 2)
339339
)
340340
)
341341
)

src/guardrails/checks/text/pii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def _mask_encoded_pii(text: str, config: PIIConfig, original_text: str | None =
726726
len(candidate_lower) >= 3
727727
and any( # Any 3-char chunk overlaps
728728
candidate_lower[i : i + 3] in detected_lower
729-
for i in range(0, len(candidate_lower) - 2, 2) # Step by 2 for efficiency
729+
for i in range(len(candidate_lower) - 2)
730730
)
731731
)
732732
)

tests/unit/checks/test_anonymizer_baseline.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ async def test_baseline_multiple_non_overlapping_entities() -> None:
4848
config,
4949
)
5050

51-
# Record baseline output - will fill in after running
51+
# Record baseline output
5252
checked_text = result.info["checked_text"]
53-
print(f"Multiple entities result: {checked_text}")
5453
assert "<EMAIL_ADDRESS>" in checked_text # noqa: S101
5554
assert "<PHONE_NUMBER>" in checked_text # noqa: S101
5655

@@ -70,7 +69,6 @@ async def test_baseline_consecutive_entities() -> None:
7069

7170
# Record baseline output
7271
checked_text = result.info["checked_text"]
73-
print(f"Consecutive entities result: {checked_text}")
7472
assert checked_text.count("<EMAIL_ADDRESS>") == 2 # noqa: S101
7573

7674

@@ -81,11 +79,9 @@ async def test_baseline_entity_at_boundaries() -> None:
8179

8280
# Email at start
8381
result_start = await pii(None, "[email protected] is the contact", config)
84-
print(f"Entity at start: {result_start.info['checked_text']}")
8582

8683
# Email at end
8784
result_end = await pii(None, "Contact: [email protected]", config)
88-
print(f"Entity at end: {result_end.info['checked_text']}")
8985

9086
assert result_start.info["checked_text"].startswith("<EMAIL_ADDRESS>") # noqa: S101
9187
assert result_end.info["checked_text"].endswith("<EMAIL_ADDRESS>") # noqa: S101
@@ -103,7 +99,6 @@ async def test_baseline_unicode_characters() -> None:
10399

104100
# Record baseline output
105101
checked_text = result.info["checked_text"]
106-
print(f"Unicode result: {checked_text}")
107102
assert "<EMAIL_ADDRESS>" in checked_text # noqa: S101
108103
assert "🔒" in checked_text # noqa: S101
109104

@@ -120,7 +115,6 @@ async def test_baseline_special_characters() -> None:
120115

121116
# Record baseline output
122117
checked_text = result.info["checked_text"]
123-
print(f"Special chars result: {checked_text}")
124118
assert "[<EMAIL_ADDRESS>]" in checked_text or "Contact: <EMAIL_ADDRESS>" in checked_text # noqa: S101
125119

126120

@@ -143,7 +137,6 @@ async def test_baseline_credit_card_masking() -> None:
143137

144138
# Record baseline output
145139
checked_text = result.info["checked_text"]
146-
print(f"Credit card result: {checked_text}")
147140
# Credit card detection may be inconsistent with certain formats
148141
if result.info["pii_detected"]:
149142
assert "<CREDIT_CARD>" in checked_text # noqa: S101
@@ -166,10 +159,6 @@ async def test_baseline_phone_number_formats() -> None:
166159
result3 = await pii(None, "Mobile: 5551234567", config)
167160
texts_and_results.append(("5551234567", result3.info["checked_text"]))
168161

169-
for original, checked in texts_and_results:
170-
print(f"Phone format '{original}': {checked}")
171-
# At least one should be detected and masked
172-
173162
# Check that at least the first format is detected
174163
assert "<PHONE_NUMBER>" in result1.info["checked_text"] # noqa: S101
175164

@@ -194,7 +183,6 @@ async def test_baseline_mixed_entities_complex() -> None:
194183

195184
# Record baseline output
196185
checked_text = result.info["checked_text"]
197-
print(f"Complex mixed result: {checked_text}")
198186

199187
# Verify all entity types are masked
200188
assert "<EMAIL_ADDRESS>" in checked_text # noqa: S101

0 commit comments

Comments
 (0)