Skip to content

Commit

Permalink
test: Use a real file since patch does not seems to work...
Browse files Browse the repository at this point in the history
  • Loading branch information
YuukanOO committed May 4, 2019
1 parent f73f765 commit 8e15610
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 2 additions & 0 deletions tests/test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[some_section]
some_key=some_value
14 changes: 3 additions & 11 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from sure import expect
from unittest.mock import patch, mock_open
from configparser import NoOptionError
from pytlas.settings import write_to_settings, config, DEFAULT_SECTION, SETTING_DEFAULT_REPO_URL, \
SETTING_SKILLS, DEFAULT_SETTING_SKILLS, DEFAULT_SETTING_DEFAULT_REPO_URL, get, set as set_setting, \
Expand All @@ -12,18 +11,11 @@ def setUp(self):
reset()

def test_it_should_load_settings_from_a_path(self):
conf = """
[some_section]
some_key=some_value
"""
conf_path = '/a/path/to/a/file.conf'
expect(get('some_key', section='some_section')).to.be.none

with patch('builtins.open', mock_open(read_data=conf)):
expect(get('some_key', section='some_section')).to.be.none
load(os.path.join(os.path.dirname(__file__), 'test.conf'))

load(conf_path)

expect(get('some_key', section='some_section')).to.equal('some_value')
expect(get('some_key', section='some_section')).to.equal('some_value')

def test_it_should_set_the_setting_even_if_the_section_does_not_exists_yet(self):
set_setting('my_key', 'a value', section='my_section')
Expand Down

0 comments on commit 8e15610

Please sign in to comment.