Sycophant.Tesla.RecorderMiddleware
(sycophant v0.4.2)
Copy Markdown
Tesla middleware for recording and replaying HTTP exchanges in tests.
In replay mode (default), reads a fixture file and returns the stored response. In record mode, passes through to the real API, captures the exchange, and writes it to disk.
The middleware is a no-op when no recording tag is set in the process dictionary, so it is safe to always include in the test middleware stack.
Usage
Set the recording name via the process dictionary before making a request:
Sycophant.Tesla.RecorderMiddleware.set_recording("openai/gpt-4o/basic")Options
:fixtures_path- directory where fixture files are stored. Defaults to"test/fixtures/recordings".:record- whentrue, forces recording (same asRECORD=force). Defaults to checking theRECORDenv var.
Environment
RECORD=true- records only missing fixtures, replays existing onesRECORD=force- re-records all fixtures regardless of existence
Summary
Functions
Clears the recording name from the process dictionary.
Gets the current recording name from the process dictionary.
Sets the recording name in the process dictionary and resets the call counter.