| 6819 | |
| 6820 | @classmethod |
| 6821 | def setUpClass(cls): |
| 6822 | def chunks(total, step): |
| 6823 | assert total >= step |
| 6824 | while total > step: |
| 6825 | yield step |
| 6826 | total -= step |
| 6827 | if total: |
| 6828 | yield total |
| 6829 | |
| 6830 | chunk = b"".join([random.choice(string.ascii_letters).encode() |
| 6831 | for i in range(cls.BUFSIZE)]) |
| 6832 | with open(os_helper.TESTFN, 'wb') as f: |
| 6833 | for csize in chunks(cls.FILESIZE, cls.BUFSIZE): |
| 6834 | f.write(chunk) |
| 6835 | with open(os_helper.TESTFN, 'rb') as f: |
| 6836 | cls.FILEDATA = f.read() |
| 6837 | assert len(cls.FILEDATA) == cls.FILESIZE |
| 6838 | |
| 6839 | @classmethod |
| 6840 | def tearDownClass(cls): |