|
1 | 1 | """Tests for internal cookie helper functions."""
|
2 | 2 |
|
| 3 | +import sys |
3 | 4 | from http.cookies import (
|
4 | 5 | CookieError,
|
5 | 6 | Morsel,
|
@@ -427,6 +428,10 @@ def test_parse_set_cookie_headers_boolean_attrs() -> None:
|
427 | 428 | assert morsel.get("httponly") is True, f"{name} should have httponly=True"
|
428 | 429 |
|
429 | 430 |
|
| 431 | +@pytest.mark.skipif( |
| 432 | + sys.version_info < (3, 14), |
| 433 | + reason="Partitioned cookies support requires Python 3.14+", |
| 434 | +) |
430 | 435 | def test_parse_set_cookie_headers_boolean_attrs_with_partitioned() -> None:
|
431 | 436 | """Test that boolean attributes including partitioned work correctly."""
|
432 | 437 | # Test secure attribute variations
|
@@ -482,6 +487,10 @@ def test_parse_set_cookie_headers_encoded_values() -> None:
|
482 | 487 | assert result[2][1].value == "%21%40%23%24%25%5E%26*%28%29"
|
483 | 488 |
|
484 | 489 |
|
| 490 | +@pytest.mark.skipif( |
| 491 | + sys.version_info < (3, 14), |
| 492 | + reason="Partitioned cookies support requires Python 3.14+", |
| 493 | +) |
485 | 494 | def test_parse_set_cookie_headers_partitioned() -> None:
|
486 | 495 | """
|
487 | 496 | Test that parse_set_cookie_headers handles partitioned attribute correctly.
|
@@ -518,6 +527,10 @@ def test_parse_set_cookie_headers_partitioned() -> None:
|
518 | 527 | assert result[4][1].get("path") == "/"
|
519 | 528 |
|
520 | 529 |
|
| 530 | +@pytest.mark.skipif( |
| 531 | + sys.version_info < (3, 14), |
| 532 | + reason="Partitioned cookies support requires Python 3.14+", |
| 533 | +) |
521 | 534 | def test_parse_set_cookie_headers_partitioned_case_insensitive() -> None:
|
522 | 535 | """Test that partitioned attribute is recognized case-insensitively."""
|
523 | 536 | headers = [
|
@@ -555,6 +568,26 @@ def test_parse_set_cookie_headers_partitioned_not_set() -> None:
|
555 | 568 |
|
556 | 569 |
|
557 | 570 | # Tests that don't require partitioned support in SimpleCookie
|
| 571 | +@pytest.mark.skipif( |
| 572 | + sys.version_info >= (3, 14), |
| 573 | + reason="Python 3.14+ has built-in partitioned cookie support", |
| 574 | +) |
| 575 | +def test_parse_set_cookie_headers_partitioned_not_set_if_no_support() -> None: |
| 576 | + headers = [ |
| 577 | + "cookie1=value1; Partitioned", |
| 578 | + "cookie2=value2; Partitioned=", |
| 579 | + "cookie3=value3; Partitioned=true", |
| 580 | + ] |
| 581 | + |
| 582 | + result = parse_set_cookie_headers(headers) |
| 583 | + |
| 584 | + assert len(result) == 3 |
| 585 | + for i, (_, morsel) in enumerate(result): |
| 586 | + assert ( |
| 587 | + morsel.get("partitioned") is None |
| 588 | + ), f"Cookie {i+1} should not have partitioned flag" |
| 589 | + |
| 590 | + |
558 | 591 | def test_parse_set_cookie_headers_partitioned_with_other_attrs_manual() -> None:
|
559 | 592 | """
|
560 | 593 | Test parsing logic for partitioned cookies combined with all other attributes.
|
|
0 commit comments