testGetFreeProxy.py 1.1 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 Util.GetConfig import GetConfig
  16. # noinspection PyPep8Naming
  17. def testGetFreeProxy():
  18. """
  19. test class GetFreeProxy in ProxyGetter/GetFreeProxy
  20. :return:
  21. """
  22. gc = GetConfig()
  23. proxy_getter_functions = gc.proxy_getter_functions
  24. for proxyGetter in proxy_getter_functions:
  25. proxy_count = 0
  26. for proxy in getattr(GetFreeProxy, proxyGetter.strip())():
  27. if proxy:
  28. print('{func}: fetch proxy {proxy}'.format(func=proxyGetter, proxy=proxy))
  29. proxy_count += 1
  30. assert proxy_count >= 20, '{} fetch proxy fail'.format(proxyGetter)
  31. if __name__ == '__main__':
  32. testGetFreeProxy()