Skip to content

Commit 7135d98

Browse files
Merge pull request #539 from cmurphy/fix-exception
Raise ValueError for invalid attribute type
2 parents c99c4a8 + e58e895 commit 7135d98

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/saml2/saml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def set_text(self, val, base64encode=False):
224224
elif typ == "xs:base64Binary":
225225
pass
226226
else:
227-
ValueError("Type and value doesn't match")
227+
raise ValueError("Type and value doesn't match")
228228
elif isinstance(val, bool):
229229
if val:
230230
val = "true"

tests/test_02_saml.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ def test_set_text(self):
243243
av.set_text(None)
244244
assert av.text == ""
245245

246+
av = AttributeValue()
247+
av.set_type('invalid')
248+
raises(ValueError, "av.set_text('free text')")
249+
246250
def test_make_vals_div(self):
247251
foo = saml2.make_vals(666, AttributeValue, part=True)
248252
assert foo.text == "666"

0 commit comments

Comments
 (0)