Handle inconsistent error messages between Python 2 and Python 3.

stix2.1
Greg Back 2017-09-29 18:45:15 +00:00
parent ffa2242878
commit b31b4f29f8
1 changed files with 3 additions and 1 deletions

View File

@ -220,7 +220,9 @@ def test_add_get_remove_filter(ds):
with pytest.raises(TypeError) as excinfo: with pytest.raises(TypeError) as excinfo:
# create Filter that has a value type that is not allowed # create Filter that has a value type that is not allowed
Filter('created', '=', object()) Filter('created', '=', object())
assert str(excinfo.value) == "Filter value type '<type 'object'>' is not supported. The type must be a python immutable type or dictionary" # On Python 2, the type of object() is `<type 'object'>` On Python 3, it's `<class 'object'>`.
assert str(excinfo.value).startswith("Filter value type")
assert str(excinfo.value).endswith("is not supported. The type must be a python immutable type or dictionary")
assert len(ds.filters) == 0 assert len(ds.filters) == 0