Skip to content
Myr

Fixes issue #669

Before adoption: this commit came in with the history the project adopted, so no landing records it.

NamedTemporaryFile was being automatically deleted on Windows thus couldn't be opened later for reading

authored by Piotr Dobrogost · committed by Piotr Dobrogost · parent f413d0e · Browse files · 1 file+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−2 removed

  • tests:+6 added−2 removed

1 file+6 added−2 removed

modified:tests/test_requests.py+6 added-2 removed
465 unmodified lines
466467 def test_file_post_data(self):468469 filecontent = b"fooaowpeufbarasjhf"470 testfile = tempfile.NamedTemporaryFile()470 testfile = tempfile.NamedTemporaryFile(delete=False)471 testfile.write(filecontent)472 testfile.flush()473 testfile.close()474475 for service in SERVICES:476477 data = open(testfile.name, "rb")476 r = post(service('post'), data=open(testfile.name, "rb"),478 r = post(service('post'), data=data,479 headers={"content-type": "application/octet-stream"})480481 data.close()482 self.assertEqual(r.status_code, 200)483 self.assertEqual(r.headers['content-type'], 'application/json')484 self.assertEqual(r.url, service('post'))485486 rbody = json.loads(r.text)487 assert rbody.get('form') in (None, {})488 self.assertEqual(rbody.get('data'), filecontent.decode('ascii'))489 os.remove(testfile.name)490491 def test_urlencoded_post_querystring(self):492493 for service in SERVICES:
456 unmodified lines