| 547 | return client |
| 548 | |
| 549 | def assert_key_contents_equal(self, bucket, key, expected_contents): |
| 550 | self.wait_until_key_exists(bucket, key) |
| 551 | if isinstance(expected_contents, BytesIO): |
| 552 | expected_contents = expected_contents.getvalue().decode('utf-8') |
| 553 | actual_contents = self.get_key_contents(bucket, key) |
| 554 | # The contents can be huge so we try to give helpful error messages |
| 555 | # without necessarily printing the actual contents. |
| 556 | assert len(actual_contents) == len(expected_contents) |
| 557 | assert actual_contents == expected_contents, ( |
| 558 | f"Contents for {bucket}/{key} do not match (but they " |
| 559 | f"have the same length)" |
| 560 | ) |
| 561 | |
| 562 | def create_bucket(self, name=None, region=None): |
| 563 | if not region: |