Skip to content

Commit 827f206

Browse files
don't write expected exceptions to console
1 parent a83ab6d commit 827f206

File tree

1 file changed

+12
-1
lines changed
  • test_vector_handlers/src/awses_test_vectors/manifests/full_message

1 file changed

+12
-1
lines changed

test_vector_handlers/src/awses_test_vectors/manifests/full_message/decrypt.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import json
99
import os
1010
from enum import Enum
11+
import contextlib
12+
import io
1113

1214
import attr
1315
import aws_encryption_sdk
@@ -126,8 +128,17 @@ def match(self, name, decrypt_fn):
126128
# The ESDK implementations are not consistent in the types of errors they produce
127129
# or the exact error messages they use. The most important thing to test is that decryption
128130
# fails in some way, and hence the overly-broad implicit try/catch here.
131+
129132
with pytest.raises(Exception):
130-
decrypt_fn()
133+
# When the exception is raised,
134+
# it will write stderrs to console.
135+
# However, this branch is expected to raise an exception,
136+
# and will write that exception to console.
137+
# Swallow the exception so CI build logs are cleaner,
138+
# and any actual issues are easier to see.
139+
f = io.StringIO()
140+
with contextlib.redirect_stderr(f):
141+
decrypt_fn()
131142
except BaseException:
132143
# Translate the exception just to attach context.
133144
raise RuntimeError(

0 commit comments

Comments
 (0)