Azure / LinuxPatchExtension

Microsoft Azure VM Guest Linux Patch Extension
Apache License 2.0
10 stars 8 forks source link

Fix broken 3-byte-unicode-related unit test in Python 2.x #264

Closed feng-j678 closed 1 month ago

feng-j678 commented 1 month ago

[x] address the failing test case (test_write_event_msg_size_limit_char_more_than_1_bytes) in py27 that it can't handle (€) 3 bytes ascii char: Non-ASCII (€) character in file line, but no encoding declared; [x] modify the test using unicode char ("a\u20acbc" ) as input instead of € [x] modify the last assertion checking the message length is less than and equal to the accept limit instead of mathematically calculating the expected message vs the actual message content. in py27, it is recognizing the above unicode as 9 bytes, but py3 recognize it as 4 bytes, therefore the calculation in the last assertion never passed. [x] remove € in __set_up_patches_func() Test_StatusHandlerTruncation.py [x] the reason for that assertion change was the unicode as 9 bytes in py2, but py3 recognize it as 4 bytes, so the calculation in the that assertion will never passed, it's very difficult to get the exact mathematical result for both. so we went with using the upper and lower bound limit in encoding to assert the truncation is applied and it's within a reasonable byte range

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.08%. Comparing base (0824ba8) to head (8195ee9). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #264 +/- ## ======================================= Coverage 91.08% 91.08% ======================================= Files 91 91 Lines 15846 15848 +2 ======================================= + Hits 14433 14435 +2 Misses 1413 1413 ``` | [Flag](https://app.codecov.io/gh/Azure/LinuxPatchExtension/pull/264/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) | Coverage Δ | | |---|---|---| | [python27](https://app.codecov.io/gh/Azure/LinuxPatchExtension/pull/264/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) | `91.08% <100.00%> (+<0.01%)` | :arrow_up: | | [python39](https://app.codecov.io/gh/Azure/LinuxPatchExtension/pull/264/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) | `91.08% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.