[Platform API][pytest] Handle both 'str' and 'unicode' string types in Python 2#2210
Merged
jleveque merged 1 commit intosonic-net:masterfrom Sep 14, 2020
jleveque:plat_api_unicode_py2
Merged
[Platform API][pytest] Handle both 'str' and 'unicode' string types in Python 2#2210jleveque merged 1 commit intosonic-net:masterfrom jleveque:plat_api_unicode_py2
jleveque merged 1 commit intosonic-net:masterfrom
jleveque:plat_api_unicode_py2
Conversation
yxieca
approved these changes
Sep 13, 2020
vdahiya12
reviewed
Sep 14, 2020
vdahiya12
approved these changes
Sep 14, 2020
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Python 2 has two string types,
strandunicode. Both share abasestringsuperclass. In Python 3, there is only onestrtype. 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
Approach
What is the motivation for this PR?
To ensure the platform API tests properly acknowledge both
strandunicodestring types returned from the API.How did you do it?
If Python 2, compare type to
basestring, if Python 3, compare type tostr.How did you verify/test it?
Test that both
strandunicodetypes are considered strings when running tests under Python 2.