Skip to content

[Platform API][pytest] Handle both 'str' and 'unicode' string types in Python 2#2210

Merged
jleveque merged 1 commit intosonic-net:masterfrom
jleveque:plat_api_unicode_py2
Sep 14, 2020
Merged

[Platform API][pytest] Handle both 'str' and 'unicode' string types in Python 2#2210
jleveque merged 1 commit intosonic-net:masterfrom
jleveque:plat_api_unicode_py2

Conversation

@jleveque
Copy link
Contributor

@jleveque jleveque commented Sep 12, 2020

Summary:
Python 2 has two string types, str and unicode. Both share a basestring superclass. In Python 3, there is only one str type. This patch allows the platform API tests to consider a string type valid whether it is ASCII (str) or Unicode in Python 2. It also future-proofs the inevitable transition to Python 3 by checking the executing Python version.

Note that test_chassis.py is not modified here, as the change is being applied as part of #2209

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

To ensure the platform API tests properly acknowledge both str and unicode string types returned from the API.

How did you do it?

If Python 2, compare type to basestring, if Python 3, compare type to str.

How did you verify/test it?

Test that both str and unicode types are considered strings when running tests under Python 2.

@jleveque jleveque merged commit 97f0fd9 into sonic-net:master Sep 14, 2020
@jleveque jleveque deleted the plat_api_unicode_py2 branch September 14, 2020 17:40
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
linkmgrrd:
* d6518dd 2022-06-14 | Fix IP header checksum in handleSendSwitchCommand (sonic-net#88) (HEAD -> 202205, github/202205) [Jing Zhang]

swss:
* 4430445 2022-06-03 | Add port counter sanity check (sonic-net#2300) (HEAD -> 202205, github/202205) [Junhua Zhai]
* 01b017c 2022-05-28 | [counter] Support gearbox counters (sonic-net#2218) [Junhua Zhai]

utilities:
* ce96543 2022-05-26 | [subinterface]Avoid removing the subinterface when last configured ip is removed (sonic-net#2181) (HEAD -> 202205, github/202205) [Sudharsan Dhamal Gopalarathnam]
* ed97c6f 2022-05-26 | [subinterface] Fix route add command to accept subinterface as dev (sonic-net#2180) [Sudharsan Dhamal Gopalarathnam]
* 53ff644 2022-06-09 | [gendump] Add Support to dump BCM-DNX commands (sonic-net#1813) [saksarav-nokia]
* 0e31790 2022-06-15 | [config][muxcable] fix minor config DB logic issue (sonic-net#2210) [vdahiya12]

Signed-off-by: Ying Xie <[email protected]>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
fc29641 [pbh] [aclorch] Fixed a bug causes by updating the flow-counter value for the PBH rule (sonic-net#2226)
6c38ef7 [QoS] Resolve an issue in the sequence where a referenced object removed and then the referencing object deleting and then re-adding (sonic-net#2210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants