def main(import_func): try: wsgi_install() add_support_for_localization() # Load Trove app # Paste file needs absolute path config_file = os.path.realpath('etc/trove/trove.conf.test') # 'etc/trove/test-api-paste.ini' app = initialize_trove(config_file) # Initialize sqlite database. initialize_database() # Swap out WSGI, httplib, and other components with test doubles. initialize_fakes(app) # Initialize the test configuration. test_config_file, repl = parse_args_for_test_config() CONFIG.load_from_file(test_config_file) import_func() from trove.tests.util import event_simulator event_simulator.run_main(functools.partial(run_tests, repl)) except Exception as e: # Printing the error manually like this is necessary due to oddities # with sys.excepthook. print("Run tests failed: %s" % e) traceback.print_exc() raise
from trove.tests.util import event_simulator event_simulator.monkey_patch() def parse_args_for_test_config(): for index in range(len(sys.argv)): arg = sys.argv[index] print(arg) if arg[:14] == "--test-config=": del sys.argv[index] return arg[14:] return 'etc/tests/localhost.test.conf' if __name__ == "__main__": try: wsgi_install() add_support_for_localization() # Load Trove app # Paste file needs absolute path config_file = os.path.realpath('etc/trove/trove.conf.test') # 'etc/trove/test-api-paste.ini' app = initialize_trove(config_file) # Initialize sqlite database. initialize_database() # Swap out WSGI, httplib, and several sleep functions # with test doubles. initialize_fakes(app) # Initialize the test configuration. test_config_file = parse_args_for_test_config() CONFIG.load_from_file(test_config_file)
event_simulator.monkey_patch() def parse_args_for_test_config(): for index in range(len(sys.argv)): arg = sys.argv[index] print(arg) if arg[:14] == "--test-config=": del sys.argv[index] return arg[14:] return 'etc/tests/localhost.test.conf' if __name__ == "__main__": try: wsgi_install() add_support_for_localization() # Load Trove app # Paste file needs absolute path config_file = os.path.realpath('etc/trove/trove.conf.test') # 'etc/trove/test-api-paste.ini' app = initialize_trove(config_file) # Initialize sqlite database. initialize_database() # Swap out WSGI, httplib, and several sleep functions # with test doubles. initialize_fakes(app) # Initialize the test configuration. test_config_file = parse_args_for_test_config() CONFIG.load_from_file(test_config_file)