mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-03 03:43:29 +03:00
Add test coverage for .from_yaml() method
This commit is contained in:
parent
24ea8acc7c
commit
0e278b604b
|
@ -647,6 +647,27 @@ class ConfigFromYamlTests(unittest.TestCase):
|
|||
'"pip install dependency-injector[yaml]"',
|
||||
)
|
||||
|
||||
def test_option_no_yaml_installed(self):
|
||||
@contextlib.contextmanager
|
||||
def no_yaml_module():
|
||||
yaml = providers.yaml
|
||||
providers.yaml = None
|
||||
|
||||
yield
|
||||
|
||||
providers.yaml = yaml
|
||||
|
||||
with no_yaml_module():
|
||||
with self.assertRaises(errors.Error) as error:
|
||||
self.config.option.from_yaml(self.config_file_1)
|
||||
|
||||
self.assertEqual(
|
||||
error.exception.args[0],
|
||||
'Unable to load yaml configuration - PyYAML is not installed. '
|
||||
'Install PyYAML or install Dependency Injector with yaml extras: '
|
||||
'"pip install dependency-injector[yaml]"',
|
||||
)
|
||||
|
||||
|
||||
class ConfigFromYamlWithEnvInterpolationTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user