Пример #1
0
 def test_should_raise_error_if_setting_configured_wrong(self):
     with patch.object(
         sys, 'argv', ['', '--settings', 'tests.samples.simple']
     ):
         with pytest.raises(RuntimeError):
             from simple_settings.core import _Settings
             _Settings()
Пример #2
0
 def test_should_raise_error_if_setting_configured_wrong(self):
     settings = _Settings()
     with patch.object(
         sys, 'argv', ['', '--settings', 'tests.samples.simple']
     ):
         with pytest.raises(RuntimeError):
             settings.foo
Пример #3
0
def get_settings_by_environment(module_name):
    settings = _Settings()

    with patch('os.environ.get') as mock:
        mock.return_value = module_name
        settings._setup()

    return settings
Пример #4
0
def get_settings_by_cmd_line(module_name):
    settings = _Settings()

    with patch.object(
        sys, 'argv', ['', '--settings={}'.format(module_name)]
    ):
        settings._setup()

    return settings
Пример #5
0
def get_settings_by_cmd_line(module_name):
    with patch.object(
        sys, 'argv', ['', '--settings={}'.format(module_name)]
    ):
        from simple_settings.core import _Settings
        return _Settings()
Пример #6
0
def get_settings_by_environment(module_name):
    with patch('os.environ.get') as mock:
        mock.return_value = module_name
        from simple_settings.core import _Settings
        return _Settings()
Пример #7
0
 def test_should_raise_error_if_dont_have_strategy_for_an_file(self):
     with patch.object(sys, 'argv', ['', '--settings=foo.bar']):
         with pytest.raises(RuntimeError):
             from simple_settings.core import _Settings
             _Settings()
Пример #8
0
 def test_should_raise_error_if_setting_not_found(self):
     with patch.object(sys, 'argv', ['', '--settings=foo']):
         with pytest.raises(RuntimeError):
             from simple_settings.core import _Settings
             _Settings()
Пример #9
0
 def test_should_raise_error_if_setting_are_not_configured(self):
     with patch.object(sys, 'argv', []):
         with pytest.raises(RuntimeError):
             from simple_settings.core import _Settings
             _Settings()
Пример #10
0
 def test_should_raise_error_if_dont_have_strategy_for_an_file(self):
     settings = _Settings()
     with patch.object(sys, 'argv', ['', '--settings=foo.bar']):
         with pytest.raises(RuntimeError):
             settings.foo
Пример #11
0
 def test_should_raise_error_if_setting_not_found(self):
     settings = _Settings()
     with patch.object(sys, 'argv', ['', '--settings=foo']):
         with pytest.raises(RuntimeError):
             settings.foo
Пример #12
0
 def test_should_raise_error_if_setting_are_not_configured(self):
     settings = _Settings()
     with patch.object(sys, 'argv', []):
         with pytest.raises(RuntimeError):
             settings.foo