Skip to content

Commit

Permalink
Improve UT by comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 authored Dec 6, 2023
1 parent b998b56 commit 8a9093a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_redis_ut.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ def test_ConfigDBConnector():


def test_ConfigDBConnector_with_statement():
gc.collect()
last_connector_count = sum(isinstance(x, swsscommon.ConfigDBConnector) for x in gc.get_objects())

# test ConfigDBConnector support 'with' statement
with swsscommon.ConfigDBConnector() as config_db:
assert config_db.db_name == ""
Expand All @@ -816,3 +819,9 @@ def test_ConfigDBConnector_with_statement():
config_db.set_entry("TEST_PORT", "Ethernet111", {"alias": "etp1x"})
allconfig = config_db.get_config()
assert allconfig["TEST_PORT"]["Ethernet111"]["alias"] == "etp1x"


# check ConfigDBConnector will release after 'with' statement
gc.collect()
current_connector_count = sum(isinstance(x, swsscommon.ConfigDBConnector) for x in gc.get_objects())
assert current_connector_count == last_connector_count

0 comments on commit 8a9093a

Please sign in to comment.