Skip to content

Commit

Permalink
Merge pull request #201 from iv-m/mockhttprequest-close
Browse files Browse the repository at this point in the history
Implement MockHTTPResponse.close
  • Loading branch information
sigmavirus24 authored Feb 6, 2024
2 parents b781744 + 983a6d2 commit 8d1dd17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/betamax/mock_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ def __init__(self, headers):
self.msg = p.parsestr(h)
self.msg.set_payload(h)

self._closed = False

def isclosed(self):
return False
return self._closed

def close(self):
self._closed = True


class EmailMessage(message.Message):
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_cassette.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,7 @@ def test_isclosed(self):

def test_is_Message(self):
assert isinstance(self.resp.msg, email.message.Message)

def test_close(self):
self.resp.close()
assert self.resp.isclosed() is True

0 comments on commit 8d1dd17

Please sign in to comment.