travis_test.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. '''
  2. Delay the Travis CI testing for Python versions so that they don't interfere with each other
  3. '''
  4. from __future__ import print_function
  5. import re
  6. import os
  7. import time
  8. import sys
  9. TRAVIS_DELAY = 0
  10. def main():
  11. '''
  12. Delay the Travis CI testing for Python versions so that they don't interfere with each other
  13. '''
  14. python_version = "{0}.{1}".format(sys.version_info[0], sys.version_info[1])
  15. if re.search(r"^3.5", python_version):
  16. total_delay = 0 * TRAVIS_DELAY
  17. print("Python 3.5 found")
  18. print("Sleeping for {0} seconds".format(total_delay))
  19. time.sleep(total_delay)
  20. elif re.search(r"^3.4", python_version):
  21. total_delay = 1 * TRAVIS_DELAY
  22. print("Python 3.4 found")
  23. print("Sleeping for {0} seconds".format(total_delay))
  24. time.sleep(total_delay)
  25. elif re.search(r"^3.3", python_version):
  26. total_delay = 2 * TRAVIS_DELAY
  27. print("Python 3.3 found")
  28. print("Sleeping for {0} seconds".format(total_delay))
  29. time.sleep(total_delay)
  30. elif re.search(r"^2.7", python_version):
  31. total_delay = 3 * TRAVIS_DELAY
  32. print("Python 2.7 found")
  33. print("Sleeping for {0} seconds".format(total_delay))
  34. time.sleep(total_delay)
  35. elif re.search(r"^2.6", python_version):
  36. total_delay = 4 * TRAVIS_DELAY
  37. print("Python 2.6 found")
  38. print("Sleeping for {0} seconds".format(total_delay))
  39. # Execute the unit tests
  40. return_code = os.system("sh travis_test.sh")
  41. # return_code comes back as 256 on failure and sys.exit is only 8-bit
  42. if return_code != 0:
  43. sys.exit(1)
  44. else:
  45. sys.exit(0)
  46. if __name__ == "__main__":
  47. main()