mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	Add test for option.from_yaml() with missing env not required
This commit is contained in:
		
							parent
							
								
									b1d00915fd
								
							
						
					
					
						commit
						8ca72b5051
					
				| 
						 | 
					@ -905,6 +905,32 @@ class ConfigFromYamlWithEnvInterpolationTests(unittest.TestCase):
 | 
				
			||||||
        self.assertIsNone(self.config.section1.value1())
 | 
					        self.assertIsNone(self.config.section1.value1())
 | 
				
			||||||
        self.assertEqual(self.config.section1.value2(), '/path')
 | 
					        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')
 | 
					    @unittest.skipIf(sys.version_info[:2] == (3, 4), 'PyYAML does not support Python 3.4')
 | 
				
			||||||
    def test_default_values(self):
 | 
					    def test_default_values(self):
 | 
				
			||||||
        os.environ['DEFINED'] = 'defined'
 | 
					        os.environ['DEFINED'] = 'defined'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user