test_requests_async.py
This file
Path
tests/test_requests_async.py
67 lines · 1.4 KiB · Python
Last changed by
Merge pull request #565 from slingamn/cookiejarKenneth Reitzbefore adoption45be14e
History of this fileTake it
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34# Path hack.5import sys, os6sys.path.insert(0, os.path.abspath('..'))78import sys9import unittest1011import select12has_poll = hasattr(select, "poll")1314from requests import async1516sys.path.append('.')17from test_requests import httpbin, RequestsTestSuite, SERVICES181920class RequestsTestSuiteUsingAsyncApi(RequestsTestSuite):21 """Requests async test cases."""2223 def patched(f):24 """Automatically send request after creation."""2526 def wrapped(*args, **kwargs):2728 request = f(*args, **kwargs)29 return async.map([request])[0]3031 return wrapped3233 # Patched requests.api functions.34 global request35 request = patched(async.request)3637 global delete, get, head, options, patch, post, put38 delete = patched(async.delete)39 get = patched(async.get)40 head = patched(async.head)41 options = patched(async.options)42 patch = patched(async.patch)43 post = patched(async.post)44 put = patched(async.put)454647 def test_entry_points(self):4849 async.request5051 async.delete52 async.get53 async.head54 async.options55 async.patch56 async.post57 async.put5859 async.map60 async.send6162 def test_select_poll(self):63 """Test to make sure we don't overwrite the poll"""64 self.assertEqual(hasattr(select, "poll"), has_poll)6566if __name__ == '__main__':67 unittest.main()