Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config_py/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from config_py.lib import import_config


import_config(globals(){arguments_str})
import_config(globals(){arguments_str})
10 changes: 4 additions & 6 deletions config_py/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ def import_config(glob, **kwargs):
env_var_name = kwargs.get('env_var', 'WSGI_ENV')
env = get_environment(env_var_name)

conf_module = '.config_{}'.format(env)
conf_package = '{}config'.format(package)
conf_module = '{}config.config_{}'.format(package, env)
try:
my_module = importlib.import_module(
conf_module,
conf_package
conf_module
)
except ModuleNotFoundError:
except ImportError:
logging.warning('There is no configuration module for environment "{}"'.format(env))
logging.warning(
'Expected module to be present "{}{}"'.format(conf_package, conf_module)
'Expected module to be present "{}"'.format(conf_module)
)
return

Expand Down
12 changes: 6 additions & 6 deletions test/bin/config_py_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def test_create_config_root(self, mock_get_cwd):

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'root', '__init__.py_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'root', '__init__.py'),
os.path.join(SCRIPT_DIR, CONF_DIR_NAME, '__init__.py')
)
)

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'root', DEV_FILE + '_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'root', DEV_FILE),
os.path.join(SCRIPT_DIR, CONF_DIR_NAME, DEV_FILE)
)
)
Expand All @@ -58,14 +58,14 @@ def test_create_config_with_env_root(self, mock_get_cwd):

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'root', 'env', '__init__.py_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'root', 'env', '__init__.py'),
os.path.join(SCRIPT_DIR, CONF_DIR_NAME, '__init__.py')
)
)

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'root', DEV_FILE + '_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'root', DEV_FILE),
os.path.join(SCRIPT_DIR, CONF_DIR_NAME, DEV_FILE)
)
)
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_create_config_package(self, mock_get_cwd):

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'package', '__init__.py_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'package', '__init__.py'),
os.path.join(
SCRIPT_DIR,
CUST_MODULE_DIST,
Expand All @@ -106,7 +106,7 @@ def test_create_config_package(self, mock_get_cwd):

self.assertTrue(
filecmp.cmp(
os.path.join(SCRIPT_DIR, 'fixtures', 'package', DEV_FILE + '_'),
os.path.join(SCRIPT_DIR, 'fixtures', 'package', DEV_FILE),
os.path.join(
SCRIPT_DIR,
CUST_MODULE_DIST,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from config_py.lib import import_config


import_config(globals(), package='my_module.', env_var='WSGI_ENV')
import_config(globals(), package='my_module.', env_var='WSGI_ENV')
4 changes: 4 additions & 0 deletions test/bin/fixtures/root/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from config_py.lib import import_config


import_config(globals(), env_var='WSGI_ENV')
4 changes: 0 additions & 4 deletions test/bin/fixtures/root/__init__.py_

This file was deleted.

4 changes: 4 additions & 0 deletions test/bin/fixtures/root/env/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from config_py.lib import import_config


import_config(globals(), env_var='MY_ENV')
4 changes: 0 additions & 4 deletions test/bin/fixtures/root/env/__init__.py_

This file was deleted.

3 changes: 1 addition & 2 deletions test/lib/lib_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def test_import_config_with_package(self, mock_importmodule, mock_getenv):
import_config(global_mock, package='my.package.')

mock_importmodule.assert_called_with(
'.config_production',
'my.package.config'
'my.package.config.config_production'
)
to_be_exported['env'] = ANY
global_mock.update.assert_called_with(to_be_exported)
Expand Down
2 changes: 1 addition & 1 deletion version/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0"
__version__ = "0.1.1"