diff options
| author | Gabriel Falcão <gabriel@nacaolivre.org> | 2021-05-14 00:25:35 +0200 |
|---|---|---|
| committer | Gabriel Falcão <gabriel@nacaolivre.org> | 2021-05-14 00:26:18 +0200 |
| commit | 367678a523f05ff094167460cc2feab198061279 (patch) | |
| tree | b7444d122cf24de245d5fbe700178616f5abde57 | |
| parent | edfb1256e4383ee6e7181d888f96d42f14781d5c (diff) | |
| download | httpretty-fix/416/boto3.tar.gz | |
fix boto3 socket errorfix/416/boto3
closes #416
| -rw-r--r-- | development.txt | 1 | ||||
| -rw-r--r-- | httpretty/core.py | 1 | ||||
| -rw-r--r-- | tests/functional/bugfixes/test_416_boto3.py | 32 |
3 files changed, 33 insertions, 1 deletions
diff --git a/development.txt b/development.txt index acbde2f..b2169af 100644 --- a/development.txt +++ b/development.txt @@ -24,3 +24,4 @@ tornado>=6.0.4 tox>=3.14.5 twine>=1.15.0 urllib3>=1.25.8 +boto3>=1.17.72 diff --git a/httpretty/core.py b/httpretty/core.py index f76aebe..ca63c2c 100644 --- a/httpretty/core.py +++ b/httpretty/core.py @@ -376,7 +376,6 @@ class FakeSockFile(object): def close(self): self.socket.close() - self.file.close() def fileno(self): return self._fileno diff --git a/tests/functional/bugfixes/test_416_boto3.py b/tests/functional/bugfixes/test_416_boto3.py new file mode 100644 index 0000000..9d11eaa --- /dev/null +++ b/tests/functional/bugfixes/test_416_boto3.py @@ -0,0 +1,32 @@ +import httpretty +import boto3 +from botocore.exceptions import ClientError + +from sure import expect + + +@httpretty.activate(allow_net_connect=False, verbose=True) +def test_boto3(): + httpretty.register_uri( + httpretty.PUT, + "https://foo-bucket.s3.amazonaws.com/foo-object", + body="""<?xml version="1.0" encoding="UTF-8"?> + <Error> + <Code>AccessDenied</Code> + <Message>Access Denied</Message> + <RequestId>foo</RequestId> + <HostId>foo</HostId> + </Error>""", + status=403 + ) + + session = boto3.Session(aws_access_key_id="foo", aws_secret_access_key="foo") + s3_client = session.client('s3') + + put_object = expect(s3_client.put_object).when.called_with( + Bucket="foo-bucket", + Key="foo-object", + Body=b"foo" + ) + + put_object.should.have.raised(ClientError, 'Access Denied') |
