OpenStack Database As A Service (Trove)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate_examples.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. # Copyright 2014 OpenStack Foundation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. #
  16. import argparse
  17. import os
  18. import sys
  19. import run_tests
  20. def import_tests():
  21. from trove.tests.examples import snippets
  22. snippets.monkey_patch_uuid_and_date()
  23. if __name__ == "__main__":
  24. parser = argparse.ArgumentParser(description='Generate Example Snippets')
  25. parser.add_argument('--fix-examples', action='store_true',
  26. help='Fix the examples rather than failing tests.')
  27. args = parser.parse_args()
  28. if args.fix_examples:
  29. os.environ['TESTS_FIX_EXAMPLES'] = 'True'
  30. # Remove the '--fix-examples' argument from sys.argv as it is not a
  31. # valid argument in the run_tests module.
  32. sys.argv.pop(sys.argv.index('--fix-examples'))
  33. run_tests.main(import_tests)