Skip to content

Commit 8a9093a

Browse files
authored
Improve UT by comments
1 parent b998b56 commit 8a9093a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_redis_ut.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,9 @@ def test_ConfigDBConnector():
805805

806806

807807
def test_ConfigDBConnector_with_statement():
808+
gc.collect()
809+
last_connector_count = sum(isinstance(x, swsscommon.ConfigDBConnector) for x in gc.get_objects())
810+
808811
# test ConfigDBConnector support 'with' statement
809812
with swsscommon.ConfigDBConnector() as config_db:
810813
assert config_db.db_name == ""
@@ -816,3 +819,9 @@ def test_ConfigDBConnector_with_statement():
816819
config_db.set_entry("TEST_PORT", "Ethernet111", {"alias": "etp1x"})
817820
allconfig = config_db.get_config()
818821
assert allconfig["TEST_PORT"]["Ethernet111"]["alias"] == "etp1x"
822+
823+
824+
# check ConfigDBConnector will release after 'with' statement
825+
gc.collect()
826+
current_connector_count = sum(isinstance(x, swsscommon.ConfigDBConnector) for x in gc.get_objects())
827+
assert current_connector_count == last_connector_count

0 commit comments

Comments
 (0)