Example #1
0
def update_with_env(config: Config) -> None:
    """
    Override config values from environment variables.
    """
    overrides = {}
    for k in config.keys():
        env_var = "TUTOR_" + k
        if env_var in os.environ:
            overrides[k] = serialize.parse(os.environ[env_var])
    config.update(overrides)
Example #2
0
 def test_parse_int(self):
     self.assertEqual(1, serialize.parse("1"))
Example #3
0
 def test_parse_weird_chars(self):
     self.assertEqual("*@google.com", serialize.parse("*@google.com"))
Example #4
0
 def test_parse_str(self):
     self.assertEqual("abcd", serialize.parse("abcd"))
Example #5
0
 def test_parse_list(self):
     self.assertEqual(["abcd"], serialize.parse('["abcd"]'))
Example #6
0
 def test_parse_invalid_format(self):
     self.assertEqual('["abcd"', serialize.parse('["abcd"'))
Example #7
0
 def test_parse_null(self):
     self.assertIsNone(serialize.parse("null"))
Example #8
0
 def test_parse_bool(self):
     self.assertEqual(True, serialize.parse("true"))
     self.assertEqual(False, serialize.parse("false"))
Example #9
0
 def test_parse_empty_string(self):
     self.assertEqual("", serialize.parse("''"))