diff options
author | mrbandrews <bandrewsny@gmail.com> | 2016-11-15 15:37:46 -0500 |
---|---|---|
committer | mrbandrews <bandrewsny@gmail.com> | 2016-11-15 15:37:46 -0500 |
commit | 307acdd3df03082295ac0f7fe9eba7dd35973bc4 (patch) | |
tree | bb4ef780e9a296c1f73fc690deaccb326322c6b0 /qa/rpc-tests/test_framework | |
parent | 018a4eb120dcdab73f07ca02d18a5c8843509d67 (diff) | |
download | bitcoin-307acdd3df03082295ac0f7fe9eba7dd35973bc4.tar.xz |
[qa] add assert_raises_message to check specific error message
Diffstat (limited to 'qa/rpc-tests/test_framework')
-rw-r--r-- | qa/rpc-tests/test_framework/util.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index bf13b7fd84..0b3585c6b2 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -531,10 +531,14 @@ def assert_greater_than(thing1, thing2): raise AssertionError("%s <= %s"%(str(thing1),str(thing2))) def assert_raises(exc, fun, *args, **kwds): + assert_raises_message(exc, None, fun, *args, **kwds) + +def assert_raises_message(exc, message, fun, *args, **kwds): try: fun(*args, **kwds) - except exc: - pass + except exc as e: + if message is not None and message not in e.error['message']: + raise AssertionError("Expected substring not found:"+e.error['message']) except Exception as e: raise AssertionError("Unexpected exception raised: "+type(e).__name__) else: |