/boto-2.5.2/tests/test.py

# · Python · 56 lines · 25 code · 6 blank · 25 comment · 5 complexity · 6c6106ab8187d83064273fc97e221a07 MD5 · raw file

  1. #!/usr/bin/env python
  2. # Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a
  5. # copy of this software and associated documentation files (the
  6. # "Software"), to deal in the Software without restriction, including
  7. # without limitation the rights to use, copy, modify, merge, publish, dis-
  8. # tribute, sublicense, and/or sell copies of the Software, and to permit
  9. # persons to whom the Software is furnished to do so, subject to the fol-
  10. # lowing conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included
  13. # in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  16. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
  17. # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
  18. # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. # IN THE SOFTWARE.
  22. import logging
  23. import sys
  24. import unittest
  25. from nose.core import run
  26. import argparse
  27. def main():
  28. parser = argparse.ArgumentParser()
  29. parser.add_argument('-t', '--service-tests', action="append", default=[],
  30. help="Run tests for a given service. This will "
  31. "run any test tagged with the specified value, "
  32. "e.g -t s3 -t ec2")
  33. known_args, remaining_args = parser.parse_known_args()
  34. attribute_args = []
  35. for service_attribute in known_args.service_tests:
  36. attribute_args.extend(['-a', '!notdefault,' +service_attribute])
  37. if not attribute_args:
  38. # If the user did not specify any filtering criteria, we at least
  39. # will filter out any test tagged 'notdefault'.
  40. attribute_args = ['-a', '!notdefault']
  41. all_args = [__file__] + attribute_args + remaining_args
  42. print "nose command:", ' '.join(all_args)
  43. if run(argv=all_args):
  44. # run will return True is all the tests pass. We want
  45. # this to equal a 0 rc
  46. return 0
  47. else:
  48. return 1
  49. if __name__ == "__main__":
  50. sys.exit(main())