当前位置: 首页>>代码示例>>Python>>正文


Python CONFIG.load_from_file方法代码示例

本文整理汇总了Python中trove.tests.config.CONFIG.load_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python CONFIG.load_from_file方法的具体用法?Python CONFIG.load_from_file怎么用?Python CONFIG.load_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trove.tests.config.CONFIG的用法示例。


在下文中一共展示了CONFIG.load_from_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import load_from_file [as 别名]
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
开发者ID:cretta,项目名称:trove,代码行数:31,代码来源:run_tests.py

示例2: ZzzDeleteInstance

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import load_from_file [as 别名]
class ZzzDeleteInstance(Example):

    @before_class
    def setup(self):
        self.client = make_client(normal_user)

    @test
    def zzz_delete_instance(self):
        global json_instance
        self.snippet(
            "delete_instance",
            "/instances/%s" % json_instance.id,
            "DELETE", 202, "Accepted",
            lambda client: client.instances.delete(json_instance.id))
        json_instance = self.client.instances.get(json_instance.id)
        assert_equal(json_instance.status, "SHUTDOWN")

    @test(depends_on=[zzz_delete_instance])
    def delete_configuration(self):
        config = STATE["CONFIGURATION"]
        self.configs = self.snippet(
            "configuration_delete",
            ("/configurations/%s" % config.id),
            "DELETE", 202, "Accepted",
            lambda client: client.configurations.delete(config.id))


if __name__ == "__main__":
    CONFIG.load_from_file("etc/tests/localhost.test.conf")
    TestProgram().run_and_exit()
开发者ID:Tesora,项目名称:tesora-trove,代码行数:32,代码来源:snippets.py

示例3: RuntimeError

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import load_from_file [as 别名]
        index += 1

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.
    from trove.tests.config import CONFIG

    # Find config file.
    if not "TEST_CONF" in os.environ:
        raise RuntimeError("Please define an environment variable named " +
                           "TEST_CONF with the location to a conf file.")
    file_path = os.path.expanduser(os.environ["TEST_CONF"])
    if not os.path.exists(file_path):
        raise RuntimeError("Could not find TEST_CONF at " + file_path + ".")
    # Load config file and then any lines we read from the arguments.
    CONFIG.load_from_file(file_path)
    for line in extra_test_conf_lines:
        CONFIG.load_from_line(line)

    # Reset values imported into tests/__init__.
    # TODO(tim.simpson): Stop importing them from there.
    from tests import initialize_globals
    initialize_globals()

    from tests import WHITE_BOX
    if WHITE_BOX:  # If white-box testing, set up the flags.
        # Handle loading up RDL's config file madness.
        initialize_rdl_config(rdl_config_file)
        if nova_flag_file:
            initialize_nova_flags(nova_flag_file)
开发者ID:cp16net,项目名称:trove-integration,代码行数:32,代码来源:int_tests.py

示例4: wsgi_install

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import load_from_file [as 别名]
        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)

        # F401 unused imports needed for tox tests
        from trove.tests.api import backups  # noqa
        from trove.tests.api import header  # noqa
        from trove.tests.api import limits  # noqa
        from trove.tests.api import flavors  # noqa
        from trove.tests.api import versions  # noqa
        from trove.tests.api import instances as rd_instances  # noqa
        from trove.tests.api import instances_actions as rd_actions  # noqa
        from trove.tests.api import instances_delete  # noqa
        from trove.tests.api import instances_mysql_down  # noqa
        from trove.tests.api import instances_resize  # noqa
        from trove.tests.api import databases  # noqa
        from trove.tests.api import datastores  # noqa
        from trove.tests.api import root  # noqa
开发者ID:wrongfan,项目名称:trove,代码行数:33,代码来源:run_tests.py

示例5: run_main

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import load_from_file [as 别名]
def run_main(test_importer):

    add_support_for_localization()

    # Strip non-nose arguments out before passing this to nosetests

    repl = False
    nose_args = []
    conf_file = "~/test.conf"
    show_elapsed = True
    groups = []
    print("RUNNING TEST ARGS :  " + str(sys.argv))
    extra_test_conf_lines = []
    rdl_config_file = None
    nova_flag_file = None
    index = 0
    while index < len(sys.argv):
        arg = sys.argv[index]
        if arg[:2] == "-i" or arg == '--repl':
            repl = True
        elif arg[:7] == "--conf=":
            conf_file = os.path.expanduser(arg[7:])
            print("Setting TEST_CONF to " + conf_file)
            os.environ["TEST_CONF"] = conf_file
        elif arg[:8] == "--group=":
            groups.append(arg[8:])
        elif arg == "--test-config":
            if index >= len(sys.argv) - 1:
                print('Expected an argument to follow "--test-conf".')
                sys.exit()
            conf_line = sys.argv[index + 1]
            extra_test_conf_lines.append(conf_line)
        elif arg[:11] == "--flagfile=":
            pass
        elif arg[:14] == "--config-file=":
            rdl_config_file = arg[14:]
        elif arg[:13] == "--nova-flags=":
            nova_flag_file = arg[13:]
        elif arg.startswith('--hide-elapsed'):
            show_elapsed = False
        else:
            nose_args.append(arg)
        index += 1

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.
    from trove.tests.config import CONFIG

    # Find config file.
    if not "TEST_CONF" in os.environ:
        raise RuntimeError("Please define an environment variable named " +
                           "TEST_CONF with the location to a conf file.")
    file_path = os.path.expanduser(os.environ["TEST_CONF"])
    if not os.path.exists(file_path):
        raise RuntimeError("Could not find TEST_CONF at " + file_path + ".")
        # Load config file and then any lines we read from the arguments.
    CONFIG.load_from_file(file_path)
    for line in extra_test_conf_lines:
        CONFIG.load_from_line(line)

    if CONFIG.white_box:  # If white-box testing, set up the flags.
        # Handle loading up RDL's config file madness.
        initialize_rdl_config(rdl_config_file)
        if nova_flag_file:
            initialize_nova_flags(nova_flag_file)

    # Set up the report, and print out how we're running the tests.
    from tests.util import report
    from datetime import datetime
    report.log("Trove Integration Tests, %s" % datetime.now())
    report.log("Invoked via command: " + str(sys.argv))
    report.log("Groups = " + str(groups))
    report.log("Test conf file = %s" % os.environ["TEST_CONF"])
    if CONFIG.white_box:
        report.log("")
        report.log("Test config file = %s" % rdl_config_file)
    report.log("")
    report.log("sys.path:")
    for path in sys.path:
        report.log("\t%s" % path)

    # Now that all configurations are loaded its time to import everything
    test_importer()

    atexit.register(_clean_up)

    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      plugins=core.DefaultPluginManager())
    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=show_elapsed,
                            known_bugs=CONFIG.known_bugs)
    MAIN_RUNNER = runner

    if repl:
        # Turn off the following "feature" of the unittest module in case
#.........这里部分代码省略.........
开发者ID:imsplitbit,项目名称:trove-integration,代码行数:103,代码来源:int_tests.py


注:本文中的trove.tests.config.CONFIG.load_from_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。