Beispiel #1
0
    def test_loading_keys_from_config_file(self):
        config = Configuration()
        config.register('num_participants', int, synonyms={
            'n',
        })
        config.register('deploy_worldwide', bool, synonyms={
            'worldwide',
        })
        with NamedTemporaryFile() as configfile:
            configfile.write(b"""
[Example Section]
num_participants = 10
worldwide = false
""")
            configfile.flush()
            config.load_from_file(configfile.name)
        config.ready = True
        assert config.get('num_participants') == 10
        assert config.get('deploy_worldwide') is False
Beispiel #2
0
    def test_loading_keys_from_config_file(self):
        config = Configuration()
        config.register("mode", six.text_type)
        config.register("num_participants", int, synonyms={"n"})
        config.register("deploy_worldwide", bool, synonyms={"worldwide"})
        mode_with_trailing_whitespace = "live    "
        contents = """
[Example Section]
mode = {}
num_participants = 10
worldwide = false
""".format(mode_with_trailing_whitespace)

        with NamedTemporaryFile() as configfile:
            configfile.write(contents.encode("utf-8"))
            configfile.flush()
            config.load_from_file(configfile.name)

        config.ready = True
        assert config.get("mode") == "live"  # whitespace stripped
        assert config.get("num_participants") == 10
        assert config.get("deploy_worldwide") is False