This is a cross platform temporary file creation. tempfile.NamedTemporary file on windows creates a secure temp file that can't be read by other processes and can't be opened a second time. For tests, we generally *want* them to be read multiple times. The test fixture writes the t
(mode)
| 152 | |
| 153 | @contextlib.contextmanager |
| 154 | def temporary_file(mode): |
| 155 | """This is a cross platform temporary file creation. |
| 156 | |
| 157 | tempfile.NamedTemporary file on windows creates a secure temp file |
| 158 | that can't be read by other processes and can't be opened a second time. |
| 159 | |
| 160 | For tests, we generally *want* them to be read multiple times. |
| 161 | The test fixture writes the temp file contents, the test reads the |
| 162 | temp file. |
| 163 | |
| 164 | """ |
| 165 | temporary_directory = tempfile.mkdtemp() |
| 166 | basename = 'tmpfile-%s' % str(random_chars(8)) |
| 167 | full_filename = os.path.join(temporary_directory, basename) |
| 168 | open(full_filename, 'w').close() |
| 169 | try: |
| 170 | with open(full_filename, mode) as f: |
| 171 | yield f |
| 172 | finally: |
| 173 | shutil.rmtree(temporary_directory) |
| 174 | |
| 175 | |
| 176 | def create_bucket(session, name=None, region=None): |
no test coverage detected