testGetFreeProxy.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: testGetFreeProxy
  5. Description : test model ProxyGetter/getFreeProxy
  6. Author : J_hao
  7. date: 2017/7/31
  8. -------------------------------------------------
  9. Change Activity:
  10. 2017/7/31:function testGetFreeProxy
  11. -------------------------------------------------
  12. """
  13. __author__ = 'J_hao'
  14. from ProxyGetter.getFreeProxy import GetFreeProxy
  15. from Config.ConfigGetter import config
  16. def testGetFreeProxy():
  17. """
  18. test class GetFreeProxy in ProxyGetter/GetFreeProxy
  19. :return:
  20. """
  21. proxy_getter_functions = config.proxy_getter_functions
  22. for proxyGetter in proxy_getter_functions:
  23. proxy_count = 0
  24. for proxy in getattr(GetFreeProxy, proxyGetter.strip())():
  25. if proxy:
  26. print('{func}: fetch proxy {proxy},proxy_count:{proxy_count}'.format(func=proxyGetter, proxy=proxy,
  27. proxy_count=proxy_count))
  28. proxy_count += 1
  29. # assert proxy_count >= 20, '{} fetch proxy fail'.format(proxyGetter)
  30. if __name__ == '__main__':
  31. testGetFreeProxy()