osc/deploy/ProxyPool/Test/testGetFreeProxy.py
2025-05-28 19:16:17 +08:00

38 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name testGetFreeProxy
Description : test model ProxyGetter/getFreeProxy
Author : J_hao
date 2017/7/31
-------------------------------------------------
Change Activity:
2017/7/31:function testGetFreeProxy
-------------------------------------------------
"""
__author__ = 'J_hao'
from ProxyGetter.getFreeProxy import GetFreeProxy
from Config.ConfigGetter import config
def testGetFreeProxy():
"""
test class GetFreeProxy in ProxyGetter/GetFreeProxy
:return:
"""
proxy_getter_functions = config.proxy_getter_functions
for proxyGetter in proxy_getter_functions:
proxy_count = 0
for proxy in getattr(GetFreeProxy, proxyGetter.strip())():
if proxy:
print('{func}: fetch proxy {proxy},proxy_count:{proxy_count}'.format(func=proxyGetter, proxy=proxy,
proxy_count=proxy_count))
proxy_count += 1
# assert proxy_count >= 20, '{} fetch proxy fail'.format(proxyGetter)
if __name__ == '__main__':
testGetFreeProxy()