Skip to content

Feature: expose configuration use_recorded_response_as_real #959

@thibaut-lo

Description

@thibaut-lo

Hi,

Thank you for this great library.

I would like to ask whether you will be open for a PR where we expose a configuration use_recorded_response_as_real.

My main use case is that I need consistency across test runs, whether I am in a record mode using the real API response (e.g., all or rewrite from pytest-recording), or in a record mode using the response from the cassette (e.g., once with an existing cassette).

There can be some randomness in responses (like generated UUIDs) from external APIs that is then used in my tested codebase, leading to a random behavior impeding test repeatability.

For such repeatability, I need stability in the responses, whether the record mode is getting real responses or using the cassette.

I haven't gone into too much into the implementation details, but it might be simple, such as not copy.deep_copy the response in the before_record_response hook, if such config is True. Defaults would be False to keep the current behavior.

I can take a stab at it, but I wanted first to get confirmation from maintainers that this can be fine as a new feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions