sonic-net / sonic-py-swsssdk

Python SONiC switch state service sdk
Other
13 stars 86 forks source link

Fix UT test_BlockUseSwsssdk() #128

Closed liuh-80 closed 2 years ago

liuh-80 commented 2 years ago

Why I did it

Fix this issue: https://github.com/sonic-net/sonic-buildimage/issues/12558 UT failed under python2: test_BlockUseSwsssdk()

  result = subprocess.run(["python", "-c", "import swsssdk;exit()"], capture_output=True, cwd=swsssdk_path)

E AttributeError: 'module' object has no attribute 'run'

How I did it

Update UT to use subprocess.check_output(), which support by both python3 and python2.

How to verify it

Pass all UT.

Which release branch to backport (provide reason below if selected)

Description for the changelog

Fix UT test_BlockUseSwsssdk()

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

liuh-80 commented 2 years ago

Tested with this PR: https://github.com/sonic-net/sonic-buildimage/pull/12565