Skip to content

Commit f5b45d2

Browse files
committed
update test cases
1 parent f452ff0 commit f5b45d2

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

test_parsers.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -1296,10 +1296,10 @@ def test_uni_parser_frequency():
12961296
def test_sync_crawl():
12971297
from concurrent.futures import ThreadPoolExecutor
12981298
uni = Uniparser()
1299-
uni.pop_frequency('https://www.baidu.com/robots.txt')
1299+
uni.pop_frequency('https://www.python.org/robots.txt')
13001300
uni = Uniparser()
13011301
crawler_rule = CrawlerRule.loads(
1302-
r'''{"name":"Test Frequency","request_args":{"method":"get","url":"https://www.baidu.com/robots.txt","headers":{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}},"parse_rules":[{"name":"__request__","chain_rules":[["udf","['https://www.baidu.com/robots.txt'] * 4",""]],"childs":""}],"regex":"^https://www.baidu.com/robots.txt"}'''
1302+
r'''{"name":"Test Frequency","request_args":{"method":"get","url":"https://www.python.org/robots.txt","headers":{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}},"parse_rules":[{"name":"__request__","chain_rules":[["udf","['https://www.python.org/robots.txt'] * 4",""]],"childs":""}],"regex":"^https://www.python.org/robots.txt"}'''
13031303
)
13041304
start_time = time.time()
13051305
pool = ThreadPoolExecutor()
@@ -1312,7 +1312,7 @@ def test_sync_crawl():
13121312
# print(cost_time)
13131313
assert cost_time < test_count
13141314
# set Frequency, download 1 times each 1 sec
1315-
uni.set_frequency('https://www.baidu.com/robots.txt', 1, 2)
1315+
uni.set_frequency('https://www.python.org/robots.txt', 1, 2)
13161316
start_time = time.time()
13171317
pool = ThreadPoolExecutor()
13181318
tasks = [
@@ -1325,9 +1325,9 @@ def test_sync_crawl():
13251325

13261326
async def test_async_crawl():
13271327
uni = Uniparser()
1328-
uni.pop_frequency('https://www.baidu.com/robots.txt')
1328+
uni.pop_frequency('https://www.python.org/robots.txt')
13291329
crawler_rule = CrawlerRule.loads(
1330-
r'''{"name":"Test Frequency","request_args":{"method":"get","url":"https://www.baidu.com/robots.txt","headers":{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}},"parse_rules":[{"name":"nonsense","chain_rules":[["udf","['https://www.baidu.com/robots.txt'] * 4",""]],"childs":""}],"regex":"^https://www.baidu.com/robots.txt"}'''
1330+
r'''{"name":"Test Frequency","request_args":{"method":"get","url":"https://www.python.org/robots.txt","headers":{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}},"parse_rules":[{"name":"nonsense","chain_rules":[["udf","['https://www.python.org/robots.txt'] * 4",""]],"childs":""}],"regex":"^https://www.python.org/robots.txt"}'''
13311331
)
13321332
start_time = time.time()
13331333
test_count = 3
@@ -1340,7 +1340,7 @@ async def test_async_crawl():
13401340
# print(cost_time)
13411341
assert cost_time < test_count
13421342
# set Frequency, download 1 times each 1 sec
1343-
uni.set_async_frequency('https://www.baidu.com/robots.txt', 1, 2)
1343+
uni.set_async_frequency('https://www.python.org/robots.txt', 1, 2)
13441344
start_time = time.time()
13451345
tasks = [
13461346
asyncio.ensure_future(uni.adownload(crawler_rule))
@@ -1393,24 +1393,24 @@ def _partial_test_parser():
13931393
from uniparser.config import GlobalConfig
13941394
GlobalConfig.GLOBAL_TIMEOUT = 5
13951395
for case in (
1396-
# test_utils,
1397-
# test_context_parser,
1398-
# test_css_parser,
1399-
# test_selectolax_parser,
1400-
# test_xml_parser,
1401-
# test_re_parser,
1402-
# test_jsonpath_parser,
1403-
# test_objectpath_parser,
1404-
# test_jmespath_parser,
1405-
# test_python_parser,
1406-
# test_udf_parser,
1407-
# test_loader_parser,
1408-
# test_time_parser,
1409-
# test_uni_parser,
1410-
# test_crawler_rule,
1411-
# test_default_usage,
1412-
# test_crawler_storage,
1413-
# test_uni_parser_frequency,
1396+
test_utils,
1397+
test_context_parser,
1398+
test_css_parser,
1399+
test_selectolax_parser,
1400+
test_xml_parser,
1401+
test_re_parser,
1402+
test_jsonpath_parser,
1403+
test_objectpath_parser,
1404+
test_jmespath_parser,
1405+
test_python_parser,
1406+
test_udf_parser,
1407+
test_loader_parser,
1408+
test_time_parser,
1409+
test_uni_parser,
1410+
test_crawler_rule,
1411+
test_default_usage,
1412+
test_crawler_storage,
1413+
test_uni_parser_frequency,
14141414
test_crawler,
14151415
test_object,
14161416
):

0 commit comments

Comments
 (0)