pytest-vts icon indicating copy to clipboard operation
pytest-vts copied to clipboard

More informative exceptions when recording not found

Open artdgn opened this issue 5 years ago • 0 comments

I recently had to make a change to a repo that's using recording in it's tests, and at first couldn't figure out why I'm getting connection-refused errors coming from responses package. It took me a while to understand that there is global patching to requests and that connection-refused errors are in fact recording-not-found errors.

Perhaps it's worth to make sure that the exception raised during various failures are making it clear that mocking is taking place and that it's failing.

Perhaps it also could be helpful to suggest a way to disable mocking in the exception.

class RecordingNotFound(Exception):
    pass

# and than
raise RecordingNotFound("Pytest VTS request-response recording not found. "
                        "If you're trying to make live connections disable "
                        "mocking by setting environment variable "
                        "PYTEST_VTS_FORCE_RECORDING to true")

artdgn avatar Mar 04 '19 02:03 artdgn