change error message in test
-import pytest
-
-import base58
from plenum.common.messages.fields import VerkeyField
from plenum.test.input_validation.utils import b58_by_len
validator = VerkeyField()
+err = 'Neither a full verkey nor an abbreviated one'
def test_non_empty_verkeys():
@@ -13,24 +11,17 @@ def test_non_empty_verkeys():
val = b58_by_len(byte_len)
as_long = validator.validate(val)
as_short = validator.validate('~' + val)
-
if byte_len == 16:
- assert (as_long ==
- 'b58 decoded value length 16 should be one of [32]')
+ assert as_long.startswith(err)
assert not as_short
elif byte_len == 32:
assert not as_long
- assert (as_short ==
- 'b58 decoded value length 32 should be one of [16]')
+ assert as_short.startswith(err)
else:
- assert (as_long ==
- 'b58 decoded value length {} should be one of [32]'
- .format(byte_len))
- assert (as_short ==
- 'b58 decoded value length {} should be one of [16]'
- .format(byte_len))
+ assert as_long.startswith(err)
+ assert as_short.startswith(err)
def test_empty_verkey():
res = validator.validate('')
- assert res == 'b58 decoded value length 0 should be one of [32]'
+ assert res.startswith(err)
\ No newline at end of file
