MediaCrawler/test/test_proxy_ip_pool.py

20 lines
616 B
Python
Raw Normal View History

2023-12-02 08:14:36 +00:00
# -*- coding: utf-8 -*-
# @Author : relakkes@gmail.com
# @Time : 2023/12/2 14:42
# @Desc :
from unittest import IsolatedAsyncioTestCase
from proxy.proxy_ip_pool import create_ip_pool
2024-04-05 02:44:05 +00:00
from proxy.types import IpInfoModel
2023-12-02 08:14:36 +00:00
class TestIpPool(IsolatedAsyncioTestCase):
async def test_ip_pool(self):
2024-04-05 02:44:05 +00:00
pool = await create_ip_pool(ip_pool_count=1, enable_validate_ip=True)
print("\n")
for i in range(3):
2023-12-02 08:14:36 +00:00
ip_proxy_info: IpInfoModel = await pool.get_proxy()
print(ip_proxy_info)
2023-12-06 15:49:56 +00:00
self.assertIsNotNone(ip_proxy_info.ip, msg="验证 ip 是否获取成功")