mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
a29d465ee8
Summary: With Facebook having been renamed Meta Platforms, we need to change the license headers. Reviewed By: fanzeyi Differential Revision: D33407812 fbshipit-source-id: b11bfbbf13a48873f0cea75f212cc7b07a68fb2e
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# pyre-strict
|
|
|
|
import configparser
|
|
import unittest
|
|
|
|
from .. import configinterpolator
|
|
|
|
|
|
class InterpolatorTest(unittest.TestCase):
|
|
def test_basic_subs(self) -> None:
|
|
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)
|