Return a unique new temporary file location to a non-existing temporary file that can safely be created without a risk of name collision.
(self, extension=None, dir_name="td", file_name="tf")
| 137 | return test_loc |
| 138 | |
| 139 | def get_temp_file(self, extension=None, dir_name="td", file_name="tf"): |
| 140 | """ |
| 141 | Return a unique new temporary file location to a non-existing temporary |
| 142 | file that can safely be created without a risk of name collision. |
| 143 | """ |
| 144 | if extension is None: |
| 145 | extension = ".txt" |
| 146 | |
| 147 | if extension and not extension.startswith("."): |
| 148 | extension = "." + extension |
| 149 | |
| 150 | file_name = file_name + extension |
| 151 | temp_dir = self.get_temp_dir(dir_name) |
| 152 | location = path.join(temp_dir, file_name) |
| 153 | return location |
| 154 | |
| 155 | def get_temp_dir(self, sub_dir_path=None): |
| 156 | """ |
no test coverage detected