test: Assert HttpOnly is unset on a minimal cookie#2025
Merged
vdusek merged 1 commit intoJul 6, 2026
Conversation
The HttpOnly-default assertion in test_set_basic_cookie checked the
nonstandard attribute 'httpOnpy', a typo for 'HttpOnly'. Since a cookie
never carries the misspelled key, has_nonstandard_attr('httpOnpy') is
always False and 'assert not ...' passed unconditionally, so the test
never verified that a minimal cookie leaves HttpOnly off.
Use the correct 'HttpOnly' key (matching how _cookies.py stores and
reads the flag, and the sibling assertion in
test_set_cookie_with_all_attributes) so the check actually validates the
default.
vdusek
approved these changes
Jul 6, 2026
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.
test_set_basic_cookiemeant to check that a minimal cookie leavesHttpOnlyunset, but the assertion looked up the wrong attribute key:
'httpOnpy'is a typo (l->p) for'HttpOnly'. Cookies never carry themisspelled key, so
has_nonstandard_attr('httpOnpy')is alwaysFalseandassert not Falsepassed unconditionally. The assertion therefore validatednothing: a regression that wrongly set
HttpOnlyon a minimal cookie would not becaught.
This corrects the key to
'HttpOnly', which is how the flag is actually stored andread in
src/crawlee/sessions/_cookies.py(rest={'HttpOnly': ''}whenhttp_onlyis set, read back viacookie.has_nonstandard_attr('HttpOnly')), andmatches the sibling assertion in
test_set_cookie_with_all_attributes. The checknow genuinely asserts the minimal-cookie default.
Issues
Testing
uv run pytest tests/unit/sessions/test_cookies.py- passes (8 passed).uv run pytest tests/unit/sessions/- passes (30 passed).uv run poe lint- passes.uv run poe type-check- no new diagnostics from this change.set
HttpOnlyon minimal cookies makes the corrected assertion fail (red),whereas the old
httpOnpyassertion still passed. On unmodified source it passes(green).
Checklist