Skip to content

Commit

Permalink
Merge pull request #228 from nephila/feature/force_str_osenv
Browse files Browse the repository at this point in the history
Force os.environ keys to correct string type
  • Loading branch information
yakky committed Dec 21, 2015
2 parents 85587ed + de714d0 commit 2c42096
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 6 additions & 6 deletions djangocms_installer/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def create_project(config_data):
Call django-admin to create the project structure
"""
env = deepcopy(dict(os.environ))
env['DJANGO_SETTINGS_MODULE'] = ('{0}.settings'.format(config_data.project_name))
env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.project_name))
env[str('PYTHONPATH')] = str(os.pathsep.join(map(shlex_quote, sys.path)))
kwargs = {}
args = []
if config_data.template:
Expand Down Expand Up @@ -388,8 +388,8 @@ def _build_settings(config_data):
def setup_database(config_data):
with chdir(config_data.project_directory):
env = deepcopy(dict(os.environ))
env['DJANGO_SETTINGS_MODULE'] = ('{0}.settings'.format(config_data.project_name))
env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.project_name))
env[str('PYTHONPATH')] = str(os.pathsep.join(map(shlex_quote, sys.path)))
commands = []

if config_data.django_version < 1.7:
Expand Down Expand Up @@ -431,8 +431,8 @@ def load_starting_page(config_data):
"""
with chdir(config_data.project_directory):
env = deepcopy(dict(os.environ))
env['DJANGO_SETTINGS_MODULE'] = ('{0}.settings'.format(config_data.project_name))
env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.project_name))
env[str('PYTHONPATH')] = str(os.pathsep.join(map(shlex_quote, sys.path)))
subprocess.check_call([sys.executable, 'starting_page.py'], env=env)
for ext in ['py', 'pyc', 'json']:
try:
Expand Down
9 changes: 3 additions & 6 deletions tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ class TestBaseConfig(unittest.TestCase):

def __init__(self, *args, **kwargs):
self.config_not_exists = self.conf('config-dump.ini')

super(TestBaseConfig, self).__init__(*args, **kwargs)

def tearDown(self):
Expand All @@ -774,12 +773,10 @@ def unused(self, config_data):
if hasattr(config_data, 'requirements'):
delattr(config_data, 'requirements')

#@patch('sys.stdout')
#@patch('sys.stderr')
def test_parse_config_file(self, *args):
"""Tests .config.__init__._parse_config_file function."""
with self.assertRaises(SystemExit) as error:
config_data = config.parse(self.args[0:1] + [self.conf('config-not-exists.ini')] + self.args[1:])
config.parse(self.args[0:1] + [self.conf('config-not-exists.ini')] + self.args[1:])
self.assertEqual(7, error.exception.code)

args = self.args[0:1] + [self.conf('config-01.ini')] + self.args[1:]
Expand Down Expand Up @@ -835,10 +832,10 @@ def test_dump_config_file(self, *args):
config_exists = self.conf('config-01.ini')

with self.assertRaises(SystemExit) as error:
config_data = config.parse(['--config-dump', config_exists] + self.args[1:] + ['-p', '.'])
config.parse(['--config-dump', config_exists] + self.args[1:] + ['-p', '.'])
self.assertEqual(8, error.exception.code)

config_data = config.parse(['--config-dump', self.config_not_exists] + self.args[1:] + ['-p', '.'])
config.parse(['--config-dump', self.config_not_exists] + self.args[1:] + ['-p', '.'])
self.assertTrue(os.path.isfile(self.config_not_exists))

fixture = copy.copy(self.config_fixture)
Expand Down

0 comments on commit 2c42096

Please sign in to comment.