| 6716 | |
| 6717 | @classmethod |
| 6718 | def setUpClass(cls): |
| 6719 | def chunks(total, step): |
| 6720 | assert total >= step |
| 6721 | while total > step: |
| 6722 | yield step |
| 6723 | total -= step |
| 6724 | if total: |
| 6725 | yield total |
| 6726 | |
| 6727 | chunk = b"".join([random.choice(string.ascii_letters).encode() |
| 6728 | for i in range(cls.BUFSIZE)]) |
| 6729 | with open(os_helper.TESTFN, 'wb') as f: |
| 6730 | for csize in chunks(cls.FILESIZE, cls.BUFSIZE): |
| 6731 | f.write(chunk) |
| 6732 | with open(os_helper.TESTFN, 'rb') as f: |
| 6733 | cls.FILEDATA = f.read() |
| 6734 | assert len(cls.FILEDATA) == cls.FILESIZE |
| 6735 | |
| 6736 | @classmethod |
| 6737 | def tearDownClass(cls): |