Skip to content

Commit 8ca72b5

Browse files
committed
Add test for option.from_yaml() with missing env not required
1 parent b1d0091 commit 8ca72b5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/providers/test_configuration_py2_py3.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,32 @@ def test_missing_envs(self):
905905
self.assertIsNone(self.config.section1.value1())
906906
self.assertEqual(self.config.section1.value2(), '/path')
907907

908+
@unittest.skipIf(sys.version_info[:2] == (3, 4), 'PyYAML does not support Python 3.4')
909+
def test_option_missing_envs(self):
910+
del os.environ['CONFIG_TEST_ENV']
911+
del os.environ['CONFIG_TEST_PATH']
912+
913+
self.config.option.from_yaml(self.config_file)
914+
915+
self.assertEqual(
916+
self.config.option(),
917+
{
918+
'section1': {
919+
'value1': None,
920+
'value2': '/path',
921+
},
922+
},
923+
)
924+
self.assertEqual(
925+
self.config.option.section1(),
926+
{
927+
'value1': None,
928+
'value2': '/path',
929+
},
930+
)
931+
self.assertIsNone(self.config.option.section1.value1())
932+
self.assertEqual(self.config.option.section1.value2(), '/path')
933+
908934
@unittest.skipIf(sys.version_info[:2] == (3, 4), 'PyYAML does not support Python 3.4')
909935
def test_default_values(self):
910936
os.environ['DEFINED'] = 'defined'

0 commit comments

Comments
 (0)