|
19 | 19 | HttpResponse, |
20 | 20 | HttpTransport, |
21 | 21 | ) |
| 22 | +import tempfile |
| 23 | +import os |
22 | 24 |
|
23 | 25 | def test_retry_code_class_variables(): |
24 | 26 | retry_policy = RetryPolicy() |
@@ -141,17 +143,19 @@ def send(self, request, **kwargs): # type: (PipelineRequest, Any) -> PipelineRe |
141 | 143 | assert not position |
142 | 144 | return HttpResponse(request, None) |
143 | 145 |
|
144 | | - file_name = 'test_retry_seekable_file' |
145 | | - with open(file_name, "w+") as f: |
146 | | - f.write('Lots of dataaaa') |
| 146 | + file = tempfile.NamedTemporaryFile(delete=False) |
| 147 | + file.write(b'Lots of dataaaa') |
| 148 | + file.close() |
147 | 149 | http_request = HttpRequest('GET', 'http://127.0.0.1/') |
148 | 150 | headers = {'Content-Type': "multipart/form-data"} |
149 | 151 | http_request.headers = headers |
150 | | - form_data_content = { |
151 | | - 'fileContent': open(file_name, 'rb'), |
152 | | - 'fileName': file_name, |
153 | | - } |
154 | | - http_request.set_formdata_body(form_data_content) |
155 | | - http_retry = RetryPolicy(retry_total = 1) |
156 | | - pipeline = Pipeline(MockTransport(), [http_retry]) |
157 | | - pipeline.run(http_request) |
| 152 | + with open(file.name, 'rb') as f: |
| 153 | + form_data_content = { |
| 154 | + 'fileContent': f, |
| 155 | + 'fileName': f.name, |
| 156 | + } |
| 157 | + http_request.set_formdata_body(form_data_content) |
| 158 | + http_retry = RetryPolicy(retry_total=1) |
| 159 | + pipeline = Pipeline(MockTransport(), [http_retry]) |
| 160 | + pipeline.run(http_request) |
| 161 | + os.unlink(f.name) |
0 commit comments