Add test for option.from_yaml() with missing env not required

This commit is contained in:
Roman Mogylatov 2021-06-21 00:15:27 -04:00
parent b1d00915fd
commit 8ca72b5051

View File

@ -905,6 +905,32 @@ class ConfigFromYamlWithEnvInterpolationTests(unittest.TestCase):
self.assertIsNone(self.config.section1.value1())
self.assertEqual(self.config.section1.value2(), '/path')
@unittest.skipIf(sys.version_info[:2] == (3, 4), 'PyYAML does not support Python 3.4')
def test_option_missing_envs(self):
del os.environ['CONFIG_TEST_ENV']
del os.environ['CONFIG_TEST_PATH']
self.config.option.from_yaml(self.config_file)
self.assertEqual(
self.config.option(),
{
'section1': {
'value1': None,
'value2': '/path',
},
},
)
self.assertEqual(
self.config.option.section1(),
{
'value1': None,
'value2': '/path',
},
)
self.assertIsNone(self.config.option.section1.value1())
self.assertEqual(self.config.option.section1.value2(), '/path')
@unittest.skipIf(sys.version_info[:2] == (3, 4), 'PyYAML does not support Python 3.4')
def test_default_values(self):
os.environ['DEFINED'] = 'defined'