getsentry / getsentry/responses

_recorder doesn't record when there's an exception

Open
#705 5 comments 0 reactions 1 assignee Claimed by @beliaev-maksim View on GitHub
bug
Dominant language
Python
Stars
4.3k
Forks
378
Avg merge
4d 1h
Merged PRs (30d)
1

Description

### Describe the bug

When decorating a function with recorder, nothing gets recorded if an exception is thrown in the function.

### Additional context

_No response_

### Version of `responses`

0.24.1

### Steps to Reproduce

```python
class MyTestCase(TestCase):

@_recorder.record(file_path="a.yaml")
def test_a(self):
requests.get("https://example.com", verify=False)

@_recorder.record(file_path="b.yaml")
def test_b(self):
requests.get("https://example.com", verify=False)
self.assertEqual(1, 2) # throws an exception
```

### Expected Result

Requests should be recorded in both tests (files a.yaml and b.yaml should be created)

### Actual Result

Requests are only recorded in a (file b.yaml is NOT created)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.