mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
import configparser
|
|
import unittest
|
|
|
|
from .. import configinterpolator
|
|
|
|
|
|
class InterpolatorTest(unittest.TestCase):
|
|
def test_basic_subs(self):
|
|
defaults = {"USER": "wez", "RECURSIVE": "a${RECURSIVE}b"}
|
|
parser = configparser.ConfigParser(
|
|
interpolation=configinterpolator.EdenConfigInterpolator(defaults)
|
|
)
|
|
parser.add_section("section")
|
|
parser.set("section", "user", "${USER}")
|
|
parser.set("section", "rec", "${RECURSIVE}")
|
|
parser.set("section", "simple", "value")
|
|
|
|
self.assertEqual("wez", parser.get("section", "user"))
|
|
self.assertEqual("value", parser.get("section", "simple"))
|
|
self.assertEqual("a${RECURSIVE}b", parser.get("section", "rec"))
|
|
|
|
actual = {}
|
|
for section in parser.sections():
|
|
actual[section] = dict(parser.items(section))
|
|
|
|
expect = {
|
|
"section": {"user": "wez", "simple": "value", "rec": "a${RECURSIVE}b"}
|
|
}
|
|
self.assertEqual(expect, actual)
|