You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better support for bytes with Should Contain #5054
We could easily enhance Should Contain so that if the container (i.e. the first argument) is bytes and the item to check (i.e. the second argument) is a string, we convert the latter to bytes. In practice it would just require something like below (plus tests and docs):
Thanks for the PR @droeland. It looks pretty good, but there are some smallish things that could be still enhanced. See the PR review for more details.
Are you @droeland planning to fix the small issues I mentioned in the PR review? If you don't have time, I can do that myself as well. I'm now more actively working with RF 7.1 and would like to get this issue closed.
Hi, I have created a pull request that addresses this issue by enhancing the should_contain keyword to handle bytes and improve error handling. The changes include:
Automatically encoding strings to bytes using 'latin-1' when the container is a bytes object.
Checking if an integer item is within the range 0-255 before converting it to bytes.
Raising a ValueError with a clear message if the integer is out of range.
Adding tests to validate the new functionality.
You can view and review the pull request here: #5176
Thanks for the PR @Abhilash-du. Similarly as the earlier #5097 it has some issues that would need to be fixed. As I explained in the comments of your PR, I want this issue closed to get RF 7.1 out soon and I needed to decide which PR to use as the base. I decided to go with the earlier one simply because I had reviewed it in detail earlier and making required changes to it is thus very fast for me. Hopefully you are interested to contribute in the future anyway!
This issue is now done. PR #5097 by @droeland was used as the base and I then made some enhancements (incl. support for bytearray in addition to bytes) in 409cff4.
Activity
[-]Enhence Should Contains for bytes[/-][+]Enhance Should Contains for bytes[/+]pekkaklarck commentedon Mar 26, 2024
We could easily enhance
Should Containso that if the container (i.e. the first argument) is bytes and the item to check (i.e. the second argument) is a string, we convert the latter to bytes. In practice it would just require something like below (plus tests and docs):droeland commentedon Mar 29, 2024
Can I take this one up?
pekkaklarck commentedon May 29, 2024
Thanks for the PR @droeland. It looks pretty good, but there are some smallish things that could be still enhanced. See the PR review for more details.
pekkaklarck commentedon Jul 3, 2024
Are you @droeland planning to fix the small issues I mentioned in the PR review? If you don't have time, I can do that myself as well. I'm now more actively working with RF 7.1 and would like to get this issue closed.
Fixes robotframework#5054, Enhances the `should_contain` keyword in t…
Abhilash-du commentedon Aug 8, 2024
Hi, I have created a pull request that addresses this issue by enhancing the
should_containkeyword to handle bytes and improve error handling. The changes include:ValueErrorwith a clear message if the integer is out of range.You can view and review the pull request here: #5176
Thank you!
pekkaklarck commentedon Aug 26, 2024
Thanks for the PR @Abhilash-du. Similarly as the earlier #5097 it has some issues that would need to be fixed. As I explained in the comments of your PR, I want this issue closed to get RF 7.1 out soon and I needed to decide which PR to use as the base. I decided to go with the earlier one simply because I had reviewed it in detail earlier and making required changes to it is thus very fast for me. Hopefully you are interested to contribute in the future anyway!
[-]Enhance Should Contains for bytes[/-][+]Better support for bytes with `Should Contain`[/+]Enhance bytes support with Should Contain (#5054)
pekkaklarck commentedon Aug 26, 2024
This issue is now done. PR #5097 by @droeland was used as the base and I then made some enhancements (incl. support for
bytearrayin addition tobytes) in 409cff4.Fixes robotframework#5054: Enhance Should Contains for bytes (robotfr…