-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix asyncio proxyfree test, use uvloop for main loop
- Loading branch information
Showing
7 changed files
with
118 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
from javsp.web.proxyfree import * | ||
import uvloop | ||
import tracemalloc | ||
|
||
from javsp.crawlers.proxyfree import get_proxy_free_url | ||
from javsp.config import CrawlerID | ||
|
||
def test_get_url(): | ||
assert get_proxy_free_url('javlib') != '' | ||
assert get_proxy_free_url('javdb') != '' | ||
async def wrap(): | ||
assert await get_proxy_free_url(CrawlerID.javlib) != None | ||
assert await get_proxy_free_url(CrawlerID.javdb) != None | ||
uvloop.run(wrap()) | ||
|
||
|
||
def test_get_url_with_prefer(): | ||
prefer_url = 'https://www.baidu.com' | ||
assert prefer_url == get_proxy_free_url('javlib', prefer_url) | ||
async def wrap(): | ||
prefer_url = 'https://www.baidu.com' | ||
assert prefer_url == await get_proxy_free_url(CrawlerID.javlib, prefer_url) | ||
uvloop.run(wrap()) | ||
|
||
if __name__ == "__main__": | ||
print(get_proxy_free_url('javlib')) | ||
async def aentry(): | ||
print(await get_proxy_free_url(CrawlerID.javlib)) | ||
|
||
tracemalloc.start() | ||
uvloop.run(aentry(), debug=True) |