Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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