diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 279c158..adbc87d 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -21,5 +21,6 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: | + python3 socks5_server.py& coverage run test.py codecov --token=$CODECOV_TOKEN diff --git a/.gitignore b/.gitignore index 59dc276..dc3e5cf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ dumpObj.py url.txt # pypi +venv/ dist/ build/ PixivPy.egg-info/ diff --git a/README.md b/README.md index 0100ab2..2e63b0b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ _Based on PixivPy: https://github.com/upbit/pixivpy_ pip install pixivpy-async ``` +## Or install with socks proxy support: +```bash +pip install pixivpy-async[socks] +``` + ## Import Package Import **async** pixivpy: @@ -76,12 +81,25 @@ Use environment variables, automatically recognized by aiohttp (not support sock Specify the proxy address, support socks5/socks4/http (not support https) +If use the socks5/socks4 proxy, make sure the package is installed with [socks proxy support](#or-install-with-socks-proxy-support). + ```python ...PixivClient(proxy="socks5://127.0.0.1:8080") ...PixivAPI(proxy="socks5://127.0.0.1:8080") ...AppPixivAPI(proxy="socks5://127.0.0.1:8080") ``` +If the package is not installed with [socks proxy support](#or-install-with-socks-proxy-support), and your application runs on Windows, please make sure that event loop uses the policy **asyncio.WindowsSelectorEventLoopPolicy** before loop runs. [#issue4536](https://github.com/aio-libs/aiohttp/issues/4536#issuecomment-579740877) + +```python +import asyncio + +if __name__ == '__main__': + policy = asyncio.WindowsSelectorEventLoopPolicy() + asyncio.set_event_loop_policy(policy) + asyncio.run(...) # use pixivpy_async with socks proxy +``` + Note that env will be ignored when a proxy is specified. ## Login @@ -115,13 +133,27 @@ await aapi.user_bookmarks_illust(2088434) await aapi.user_following(7314824) await aapi.user_follower(275527) await aapi.user_mypixiv(275527) +await aapi.user_related(...) +await aapi.user_follow_add(...) +await aapi.user_follow_del(...) +await aapi.user_bookmark_tags_illust(...) +await aapi.user_list(...) +await aapi.search_user(...) await aapi.trending_tags_illust() await aapi.search_illust(first_tag, search_target='partial_match_for_tags') await aapi.illust_ranking('day_male') await aapi.illust_follow(req_auth=True) await aapi.illust_recommended(req_auth=True) await aapi.illust_ranking('day', date='2016-08-01') +await aapi.illust_bookmark_detail(...) +await aapi.illust_bookmark_add(...) +await aapi.illust_bookmark_delete(...) await aapi.download(image_url, path=directory, name=name) +await aapi.search_novel(...) +await aapi.user_novels(...) +await aapi.novel_series(...) +await aapi.novel_detail(...) +await aapi.novel_text(...) await papi.works(46363414) await papi.users(1184799) diff --git a/README.zh-cn.md b/README.zh-cn.md index cd57e5d..cacab61 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -24,6 +24,12 @@ _基于PixivPy: https://github.com/upbit/pixivpy_ pip install pixivpy-async --upgrade ``` +## 或安装本库并安装socks代理支持 + +```bash +pip install pixivpy-async[socks] +``` + ## 导入 导入 pixivpy-async: @@ -76,12 +82,25 @@ Pixivpy-Async支持多种代理模式,均需在Init时指定。 指定代理地址,支持socks5/socks4/http(不支持https) +如果使用的是socks5/socks4代理,请确保安装的本库拥有[socks代理支持](#或安装本库并安装socks代理支持) + ```python ...PixivClient(proxy="socks5://127.0.0.1:8080") ...PixivAPI(proxy="socks5://127.0.0.1:8080") ...AppPixivAPI(proxy="socks5://127.0.0.1:8080") ``` +如果本库安装时没有安装[socks代理支持](#或安装本库并安装socks代理支持),并且你的应用运行在Windows上,请确保事件循环在运行前将策略设置为 **asyncio.WindowsSelectorEventLoopPolicy**。 [#issue4536](https://github.com/aio-libs/aiohttp/issues/4536#issuecomment-579740877) + +```python +import asyncio + +if __name__ == '__main__': + policy = asyncio.WindowsSelectorEventLoopPolicy() + asyncio.set_event_loop_policy(policy) + asyncio.run(...) # use pixivpy_async with socks proxy +``` + 注意,指定了proxy后env会被忽略。 ## 登录 @@ -116,16 +135,31 @@ await aapi.user_bookmarks_illust(2088434) await aapi.user_following(7314824) await aapi.user_follower(275527) await aapi.user_mypixiv(275527) +await aapi.user_related(...) +await aapi.user_follow_add(...) +await aapi.user_follow_del(...) +await aapi.user_bookmark_tags_illust(...) +await aapi.user_list(...) +await aapi.search_user(...) await aapi.trending_tags_illust() await aapi.search_illust(first_tag, search_target='partial_match_for_tags') await aapi.illust_ranking('day_male') await aapi.illust_follow(req_auth=True) await aapi.illust_recommended(req_auth=True) +await aapi.illust_bookmark_detail(...) +await aapi.illust_bookmark_add(...) +await aapi.illust_bookmark_delete(...) await aapi.illust_ranking('day', date='2016-08-01') await aapi.download(image_url, path=directory, name=name) +await aapi.search_novel(...) +await aapi.user_novels(...) +await aapi.novel_series(...) +await aapi.novel_detail(...) +await aapi.novel_text(...) + await papi.works(46363414) await papi.users(1184799) await papi.me_feeds(show_r18=0) diff --git a/pixivpy_async/__init__.py b/pixivpy_async/__init__.py index 799a20d..01ff574 100644 --- a/pixivpy_async/__init__.py +++ b/pixivpy_async/__init__.py @@ -1,7 +1,7 @@ """ Pixiv API library """ -__version__ = '1.2.12' +__version__ = '1.2.13' from .aapi import AppPixivAPI from .papi import PixivAPI diff --git a/pixivpy_async/aapi.py b/pixivpy_async/aapi.py index 7edd354..4811fac 100644 --- a/pixivpy_async/aapi.py +++ b/pixivpy_async/aapi.py @@ -216,6 +216,21 @@ async def user_bookmarks_illust( ) return await self.requests_(method=method, url=url, params=params, auth=req_auth) + async def user_related( + self, + seed_user_id, + filter: str = 'for_ios', + offset: int = None, + req_auth: bool = True + ): + method, url = self.api.user_related + params = self.set_params( + seed_user_id=seed_user_id, + filter=filter, + offset=offset + ) + return await self.requests_(method=method, url=url, params=params, auth=req_auth) + # 关注用户的新作 # restrict: ["public", "private"] async def illust_follow( @@ -290,10 +305,11 @@ async def illust_recommended( max_bookmark_id_for_recommend: int = None, min_bookmark_id_for_recent_illust: int = None, offset: int = None, - include_ranking_illusts=None, + include_ranking_illusts = None, bookmark_illust_ids: list = None, include_privacy_policy=None, - req_auth: bool = True + req_auth: bool = True, + viewed: [int] = None ) -> dict: if req_auth: method, url = self.api.illust_recommended_auth @@ -303,6 +319,7 @@ async def illust_recommended( content_type=content_type, offset=offset, filter=filter, + viewed=viewed, bookmark_illust_ids=bookmark_illust_ids, include_ranking_illusts=include_ranking_illusts, include_ranking_label=include_ranking_label, @@ -596,6 +613,58 @@ async def search_novel( ) return await self.requests_(method=method, url=url, params=params, auth=req_auth) + async def user_novels( + self, + user_id: int, + filter: str = 'for_ios', + offset: int = None, + req_auth: bool = True + ): + method, url = self.api.user_novels + params = self.set_params( + user_id=user_id, + filter=filter, + offset=offset + ) + return await self.requests_(method=method, url=url, params=params, auth=req_auth) + + async def novel_series( + self, + series_id: int, + filter: str = 'for_ios', + last_order=None, + req_auth: bool = True + ): + method, url = self.api.novel_series + params = self.set_params( + series_id=series_id, + filter=filter, + last_order=last_order + ) + return await self.requests_(method=method, url=url, params=params, auth=req_auth) + + async def novel_detail( + self, + novel_id: int, + req_auth: bool = True + ): + method, url = self.api.novel_detail + params = self.set_params( + novel_id=novel_id, + ) + return await self.requests_(method=method, url=url, params=params, auth=req_auth) + + async def novel_text( + self, + novel_id: int, + req_auth: bool = True + ): + method, url = self.api.novel_text + params = self.set_params( + novel_id=novel_id, + ) + return await self.requests_(method=method, url=url, params=params, auth=req_auth) + # 特辑详情 (无需登录,调用Web API) async def showcase_article( self, diff --git a/pixivpy_async/api.py b/pixivpy_async/api.py index 9440e8b..fac4c25 100644 --- a/pixivpy_async/api.py +++ b/pixivpy_async/api.py @@ -1,5 +1,6 @@ class API: - def __init__(self, app_hosts="https://app-api.pixiv.net", + def __init__(self, + app_hosts="https://app-api.pixiv.net", pub_hosts="https://public-api.secure.pixiv.net", auth_hosts="https://oauth.secure.pixiv.net"): self.appv1 = '%s/v1' % app_hosts @@ -25,6 +26,10 @@ def user_illusts(self): def user_bookmarks_illust(self): return 'GET', '%s/user/bookmarks/illust' % self.appv1 + @property + def user_related(self): + return 'GET', '%s/user/related' % self.appv1 + @property def illust_follow(self): return 'GET', '%s/illust/follow' % self.appv2 @@ -87,11 +92,11 @@ def user_follower(self): @property def user_follow_add(self): - return 'GET', '%s/user/follow/add' % self.appv1 + return 'POST', '%s/user/follow/add' % self.appv1 @property def user_follow_del(self): - return 'GET', '%s/user/follow/add' % self.appv1 + return 'POST', '%s/user/follow/delete' % self.appv1 @property def user_mypixiv(self): @@ -113,6 +118,22 @@ def search_user(self): def search_novel(self): return 'GET', '%s/search/novel' % self.appv1 + @property + def user_novels(self): + return 'GET', '%s/user/novels' % self.appv1 + + @property + def novel_series(self): + return 'GET', '%s/novel/series' % self.appv2 + + @property + def novel_detail(self): + return 'GET', '%s/novel/detail' % self.appv2 + + @property + def novel_text(self): + return 'GET', '%s/novel/text' % self.appv1 + """ Public API """ @@ -169,7 +190,8 @@ def users_works(self, author_id): return 'GET', '%s/users/%d/works.json' % (self.apiv1, author_id) def users_favorite_works(self, author_id): - return 'GET', '%s/users/%d/favorite_works.json' % (self.apiv1, author_id) + return 'GET', '%s/users/%d/favorite_works.json' % (self.apiv1, + author_id) def users_feeds(self, author_id): return 'GET', '%s/users/%d/feeds.json' % (self.apiv1, author_id) diff --git a/pixivpy_async/client.py b/pixivpy_async/client.py index 01a6a9d..d3770fe 100644 --- a/pixivpy_async/client.py +++ b/pixivpy_async/client.py @@ -1,8 +1,7 @@ import asyncio import aiohttp -from aiohttp_socks import ProxyConnector -from .bypass_sni import get_bypass_client +from .bypass_sni import get_bypass_client class PixivClient: def __init__(self, limit=30, timeout=10, env=False, internal=False, proxy=None, bypass=False): @@ -19,20 +18,37 @@ def __init__(self, limit=30, timeout=10, env=False, internal=False, proxy=None, If you want to use proxy chaining, read https://github.com/romis2012/aiohttp-socks. """ + + if proxy: + try: + from aiohttp_socks import ProxyConnector + self.conn = ProxyConnector.from_url(proxy, limit_per_host=limit) + _flag = False + except ModuleNotFoundError as e: + if proxy.startswith('socks'): + raise e + else: + self.conn = aiohttp.TCPConnector(limit_per_host=limit) + _flag = True + else: + self.conn = aiohttp.TCPConnector(limit_per_host=limit) + self.internal = internal + if bypass: self.client = get_bypass_client() else: - if proxy: - self.conn = ProxyConnector.from_url(proxy, limit_per_host=limit) - else: - self.conn = aiohttp.TCPConnector(limit_per_host=limit) self.client = aiohttp.ClientSession( connector=self.conn, timeout=aiohttp.ClientTimeout(total=timeout), trust_env=env, ) + if proxy and _flag: + from functools import partial + self.client.get = partial(self.client.get, proxy=proxy) + self.client.post = partial(self.client.post, proxy=proxy) + def start(self): return self.client diff --git a/pixivpy_async/utils.py b/pixivpy_async/utils.py index 9598fef..9017a95 100644 --- a/pixivpy_async/utils.py +++ b/pixivpy_async/utils.py @@ -66,7 +66,10 @@ def parse_qs(next_url): query = up.urlparse(next_url).query for key, value in up.parse_qs(query).items(): if '[' in key and key.endswith(']'): - result_qs[key.split('[')[0]] = value + if key.split('[')[0] in result_qs: + result_qs[key.split('[')[0]].extend(value) + else: + result_qs[key.split('[')[0]] = value else: result_qs[key] = value[-1] diff --git a/requirements.txt b/requirements.txt index 329928d..4a9ab68 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ aiohttp[speedups] aiofiles aiohttp-socks +pysocks \ No newline at end of file diff --git a/setup.py b/setup.py index 7d46838..75fb47a 100644 --- a/setup.py +++ b/setup.py @@ -23,5 +23,10 @@ keywords=['pixiv', 'api', 'pixivpy', 'pixivpy_async'], packages=['pixivpy_async'], install_requires=['aiohttp[speedups]', 'aiofiles'], + extra_requires={ + 'socks': [ + 'aiohttp_socks', + ] + }, python_requires='>=3.5.3', ) \ No newline at end of file diff --git a/socks5_server.py b/socks5_server.py new file mode 100644 index 0000000..af7802d --- /dev/null +++ b/socks5_server.py @@ -0,0 +1,100 @@ +# Modified From https://github.com/rushter/socks5 + +import logging +import select +import socket +import struct +from socketserver import ThreadingMixIn, TCPServer, StreamRequestHandler + +logging.basicConfig(level=logging.DEBUG) +SOCKS_VERSION = 5 + + +class ThreadingTCPServer(ThreadingMixIn, TCPServer): + pass + + +class SocksProxy(StreamRequestHandler): + username = 'username' + password = 'password' + + def handle(self): + # logging.info('Accepting connection from %s:%s' % self.client_address) + + # greeting header + # read and unpack 2 bytes from a client + header = self.connection.recv(2) + version, nmethods = struct.unpack("!BB", header) + + # socks 5 + assert version == SOCKS_VERSION + assert nmethods > 0 + + # send welcome message + self.connection.recv(nmethods) + self.connection.sendall(struct.pack("!BB", SOCKS_VERSION, 0)) + + # request + version, cmd, _, address_type = struct.unpack("!BBBB", self.connection.recv(4)) + assert version == SOCKS_VERSION + + if address_type == 1: # IPv4 + address = socket.inet_ntoa(self.connection.recv(4)) + elif address_type == 3: # Domain name + domain_length = self.connection.recv(1)[0] + address = self.connection.recv(domain_length) + address = socket.gethostbyname(address) + port = struct.unpack('!H', self.connection.recv(2))[0] + + # reply + try: + if cmd == 1: # CONNECT + remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + remote.connect((address, port)) + bind_address = remote.getsockname() + # logging.info('Connected to %s %s' % (address, port)) + else: + self.server.close_request(self.request) + + addr = struct.unpack("!I", socket.inet_aton(bind_address[0]))[0] + port = bind_address[1] + reply = struct.pack("!BBBBIH", SOCKS_VERSION, 0, 0, 1, + addr, port) + + except Exception as err: + logging.error(err) + # return connection refused error + reply = self.generate_failed_reply(address_type, 5) + + self.connection.sendall(reply) + + # establish data exchange + if reply[1] == 0 and cmd == 1: + self.exchange_loop(self.connection, remote) + + self.server.close_request(self.request) + + def generate_failed_reply(self, address_type, error_number): + return struct.pack("!BBBBIH", SOCKS_VERSION, error_number, 0, address_type, 0, 0) + + def exchange_loop(self, client, remote): + + while True: + + # wait until client or remote is available for read + r, w, e = select.select([client, remote], [], []) + + if client in r: + data = client.recv(4096) + if remote.send(data) <= 0: + break + + if remote in r: + data = remote.recv(4096) + if client.send(data) <= 0: + break + + +if __name__ == '__main__': + with ThreadingTCPServer(('127.0.0.1', 9011), SocksProxy) as server: + server.serve_forever() \ No newline at end of file diff --git a/test.py b/test.py index 82eaf80..f3b2339 100644 --- a/test.py +++ b/test.py @@ -15,7 +15,7 @@ _USERNAME = "userbay" _PASSWORD = "UserPay" -_TOKEN = "uXooTT7xz9v4mflnZqJUO7po9W5ciouhKrIDnI2Dv3c" +_TOKEN = "0zeYA-PllRYp1tfrsq_w3vHGU1rPy237JMf5oDt73c4" aapi = AppPixivAPI(bypass=True) papi = PixivAPI(bypass=True) @@ -23,75 +23,59 @@ aapi.login(refresh_token=_TOKEN) t = time.time() - -async def async_func(): - from pixivpy_async import PixivClient - from pixivpy_async import AppPixivAPI as apapi - from pixivpy_async import PixivAPI as ppapi - - async with PixivClient() as client: - aapid = apapi(client=client,bypass=True) - await aapid.login(refresh_token=_TOKEN) - # await aapid.login( username=_USERNAME, password=_PASSWORD) - await aapid.illust_detail(59580629) - await aapid.illust_comments(59580629) - await aapid.ugoira_metadata(51815717) - await aapid.illust_recommended(bookmark_illust_ids=[59580629]) - await aapid.illust_related(59580629) - await aapid.user_detail(275527) - await aapid.user_illusts(275527) - await aapid.user_bookmarks_illust(2088434) - await aapid.user_following(7314824) - await aapid.user_follower(275527) - await aapid.user_follow_add(24687177) - await aapid.user_follow_del(24687177) - await aapid.user_mypixiv(275527) - await aapid.trending_tags_illust() - await aapid.illust_ranking('day_male') - await aapid.illust_follow(req_auth=True) - await aapid.illust_recommended(req_auth=True) - await aapid.illust_ranking('day', date='2016-08-01') - - # papid = ppapi(client=client) - # await papid.login( username=_USERNAME, password=_PASSWORD) - # await papid.works(46363414), - # await papid.users(1184799), - # await papid.me_feeds(show_r18=0), - # await papid.me_favorite_works(publicity='private'), - # await papid.me_following_works(), - # await papid.me_following(), - # await papid.users_works(1184799), - # await papid.users_favorite_works(1184799), - # await papid.users_feeds(1184799, show_r18=0), - # await papid.users_following(4102577), - # await papid.ranking('illust', 'weekly', 1), - # await papid.ranking(ranking_type='all', mode='daily', page=1, date='2015-05-01'), - # await papid.search_works("五航戦 姉妹", page=1, mode='text'), - # await papid.latest_works() - - class TestMethods(unittest.TestCase): def test_login(self): newaapi = AppPixivAPI(bypass=True) # newpapi = PixivAPI() # self.assertIsNotNone(newaapi.login(_USERNAME, _PASSWORD)) - self.assertIsNotNone(newaapi.login(refresh_token=_TOKEN)) + credential = newaapi.login(refresh_token=_TOKEN) + self.assertIsNotNone(credential) + self.assertIsNotNone(credential.access_token) + self.assertIsNotNone(credential.refresh_token) # self.assertIsNotNone(newpapi.login(_USERNAME, _PASSWORD)) - def test_illust_0(self): - - self.assertIsNotNone(aapi.illust_detail(59580629)) + def test_socks_1(self): + newaapi = AppPixivAPI(proxy="socks5://127.0.0.1:9011") + credential = newaapi.login(refresh_token=_TOKEN) + self.assertIsNotNone(credential) + self.assertIsNotNone(credential.access_token) + self.assertIsNotNone(credential.refresh_token) + + detail = newaapi.user_detail(275527) + self.assertIsNotNone(detail) + self.assertIsNotNone(detail.user) + self.assertEqual(detail.user.id, 275527) + + def test_socks_2(self): + os.environ['ALL_PROXY']="socks5://127.0.0.1:9011" + newaapi = AppPixivAPI(env=True) + credential = newaapi.login(refresh_token=_TOKEN) + self.assertIsNotNone(credential) + self.assertIsNotNone(credential.access_token) + self.assertIsNotNone(credential.refresh_token) + + detail = newaapi.user_detail(275527) + self.assertIsNotNone(detail) + self.assertIsNotNone(detail.user) + self.assertEqual(detail.user.id, 275527) def test_illust_1(self): - self.assertIsNotNone(aapi.illust_comments(59580629)) + illust = aapi.illust_detail(59580629) + self.assertIsNotNone(illust) + self.assertIsNotNone(illust,illust) + self.assertEqual(illust.illust.id, 59580629) + self.assertIsNotNone(illust.illust.image_urls) def test_illust_2(self): - self.assertIsNotNone(aapi.ugoira_metadata(51815717)) + self.assertIsNotNone(aapi.illust_comments(59580629)) def test_illust_3(self): - self.assertIsNotNone(aapi.illust_related(59580629)) + self.assertIsNotNone(aapi.ugoira_metadata(51815717)) def test_illust_4(self): + self.assertIsNotNone(aapi.illust_related(59580629)) + + def test_illust_5(self): self.assertIsNotNone(aapi.illust_bookmark_detail(59580629)) def test_page(self): @@ -101,15 +85,24 @@ def test_page(self): self.assertIsNotNone(aapi.parse_qs(json_result.next_url)) # page down in some case next_qs = aapi.parse_qs(json_result.next_url) self.assertIsNotNone(aapi.illust_recommended(**next_qs)) + - def test_user(self): + def test_user_1(self): self.assertIsNotNone(aapi.user_detail(275527)) - def test_user_1(self): + def test_user_2(self): self.assertIsNotNone(aapi.user_illusts(275527)) - def test_user_2(self): + def test_user_3(self): self.assertIsNotNone(aapi.user_list(2088434)) + + def test_user_4(self): + self.assertIsNotNone(aapi.user_related(7314824)) + + def test_user_5(self): + self.assertIsNotNone(aapi.search_user('ほし')) + self.assertIsNotNone(aapi.user_bookmark_tags_illust()) + def test_bookmark(self): self.assertIsNotNone(aapi.user_bookmarks_illust(2088434)) @@ -120,16 +113,29 @@ def test_bookmark(self): # def test_showcase(self): # self.assertIsNotNone(aapi.showcase_article(4616)) - def test_follow(self): - + def test_follow_1(self): self.assertIsNotNone(aapi.user_following(7314824)) - def test_follow_1(self): + def test_follow_2(self): self.assertIsNotNone(aapi.user_follower(275527)) + + def test_follow_3(self): self.assertIsNotNone(aapi.user_mypixiv(275527)) - def test_tag(self): + def test_add(self): + self.assertIsNot(aapi.user_follow_add(24687177), {}) + + def test_del(self): + self.assertIsNot(aapi.user_follow_del(24687177), {}) + def test_novel(self): + self.assertIsNotNone(aapi.search_novel('abc')) + self.assertIsNotNone(aapi.user_novels(2748828)) + self.assertIsNotNone(aapi.novel_series(0)) + self.assertIsNotNone(aapi.novel_detail(14588477)) + self.assertIsNotNone(aapi.novel_text(14588477)) + + def test_tag(self): self.assertIsNotNone(aapi.trending_tags_illust()) first_tag = None response = aapi.trending_tags_illust() @@ -149,6 +155,7 @@ def test_bookmark_add(self): illust_id = 74187223 tags = ['Fate/GO', '50000users入り', '私服'] self.assertIsNotNone(aapi.illust_bookmark_add(illust_id, tags=tags)) + self.assertIsNotNone(aapi.illust_bookmark_delete(illust_id)) self.assertIsNotNone(aapi.illust_bookmark_detail(illust_id)) def test_download(self): @@ -218,14 +225,6 @@ def test_http_methods(self): self.assertIsNotNone(loop.run_until_complete(Net().post('https://httpbin.org/post', None, {'accept': 'application/json'}, None))) self.assertIsNotNone(loop.run_until_complete(Net().delete('https://httpbin.org/delete', {'accept': 'application/json'}, None))) - # def test_async_gather(self): - # c = time.time() - # print('Sync Func: %s s' % (c - t)) - # p = asyncio.gather(async_func()) - # loop = asyncio.get_event_loop() - # loop.run_until_complete(p) -# print('Async Func: %s s' % (time.time() - c)) - if __name__ == '__main__': unittest.main()