Skip to content

Commit

Permalink
[tests] add test to cover correct exception handling in python wrapper (
Browse files Browse the repository at this point in the history
#486)

To cover fix #415
  • Loading branch information
stepanblyschak authored May 26, 2021
1 parent 73d0e2d commit 2ff1fcb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_redis_ut.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def test_ConfigDBSubscribe():
table_name = 'TEST_TABLE'
test_key = 'key1'
test_data = {'field1': 'value1'}
global output_data
global output_data
global stop_listen_thread
output_data = ""
stop_listen_thread = False
Expand Down Expand Up @@ -514,3 +514,13 @@ def listen_thread_func(config_db):

config_db.unsubscribe(table_name)
assert table_name not in config_db.handlers


def test_DBConnectFailure():
""" Verify that a DB connection failure will not cause a process abort
but transfer exception from C++ to python SWIG wrapper. """

nonexisting_host = "."
with pytest.raises(RuntimeError):
db = swsscommon.DBConnector(0, nonexisting_host, 0)

0 comments on commit 2ff1fcb

Please sign in to comment.