Skip to content

test_replays_response_from_cassette fails because of X-Amzn-Trace-Id #184

Description

@FelixSchwarz
$ pytest tests/integration/test_record_modes.py
.F......                                                                [100%]
================================== FAILURES ===================================
_____________ TestRecordOnce.test_replays_response_from_cassette ______________

            assert r0_headers == r1_headers
>           assert r0.content == r1.content
E           assert b'{\n  "args"...org/get"\n}\n' == b'{\n  "args"...org/get"\n}\n'
E             At index 208 diff: b'd' != b'e'
E             Full diff:
E               (
E                b'{\n  "args": {}, \n  "headers": {\n    "Accept": "*/*", \n    "Accept-Encodi'
E                b'ng": "gzip, deflate", \n    "Host": "httpbin.org", \n    "User-Agent": "py'
E             -  b'thon-requests/2.23.0", \n    "X-Amzn-Trace-Id": "Root=1-5e91e8b3-e94687be'
E             ?                                                                     ^^^^ ^^^...
E             
E             ...Full output truncated (9 lines hidden), use '-vv' to show

tests/integration/test_record_modes.py:43: AssertionError

The test code already removes some headers which may differ between requests but the difference shown above is in r1.content and I don't know what the best way is to ignore X-Amzn-Trace-Id there.

It seems as if httpbin.org uses Amazon's Elastic Load Balancing which adds a unique X-Amzn-Trace-Id header. That header is different for each request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions