From 8ca72b5051d62559a00972daaae94f13ed592583 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Mon, 21 Jun 2021 00:15:27 -0400 Subject: [PATCH] Add test for option.from_yaml() with missing env not required --- .../providers/test_configuration_py2_py3.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/providers/test_configuration_py2_py3.py b/tests/unit/providers/test_configuration_py2_py3.py index 25f76e27..70d2a6fb 100644 --- a/tests/unit/providers/test_configuration_py2_py3.py +++ b/tests/unit/providers/test_configuration_py2_py3.py @@ -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'