Skip to content

Commit

Permalink
fix issue with creating default config
Browse files Browse the repository at this point in the history
  • Loading branch information
imomaliev committed Jan 2, 2019
1 parent 80e9bba commit dd485e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ptrepl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.9.4'
__version__ = '0.9.5'
3 changes: 2 additions & 1 deletion ptrepl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def get_config_file():
with path.open('r') as _config_file:
config = json.load(_config_file)
else:
with open(path, 'w') as _config_file:
path.parent.mkdir(parents=True)
with open(path, 'w+') as _config_file:
config = {'settings': {}}
_config_file.write(json.dumps(config))
return config
Expand Down
11 changes: 11 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

import pytest

from ptrepl.config import get_config_file


def test_config_file_created(mocker, tmp_path):
mocker.patch('ptrepl.config.XDG_CONFIG_HOME', tmp_path)
get_config_file()
assert os.path.exists(os.path.join(tmp_path, 'ptrepl/config.json'))

0 comments on commit dd485e3

Please sign in to comment.