#11: Fixed parsing of punctuation in configuration file.
This commit is contained in:
parent
5c58f85be1
commit
6dc0173b74
2 changed files with 40 additions and 7 deletions
29
atticmatic/tests/integration/test_config.py
Normal file
29
atticmatic/tests/integration/test_config.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
try:
|
||||
# Python 2
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from io import StringIO
|
||||
|
||||
from collections import OrderedDict
|
||||
import string
|
||||
|
||||
from atticmatic import config as module
|
||||
|
||||
|
||||
def test_parse_section_options_with_punctuation_should_return_section_options():
|
||||
parser = module.RawConfigParser()
|
||||
parser.readfp(StringIO('[section]\nfoo: {}\n'.format(string.punctuation)))
|
||||
|
||||
section_format = module.Section_format(
|
||||
'section',
|
||||
(module.Config_option('foo', str, required=True),),
|
||||
)
|
||||
|
||||
config = module.parse_section_options(parser, section_format)
|
||||
|
||||
assert config == OrderedDict(
|
||||
(
|
||||
('foo', string.punctuation),
|
||||
)
|
||||
)
|
||||
|
|
@ -198,7 +198,7 @@ def test_parse_section_options_for_missing_section_should_return_empty_dict():
|
|||
def insert_mock_parser():
|
||||
parser = flexmock()
|
||||
parser.should_receive('read')
|
||||
module.ConfigParser = lambda: parser
|
||||
module.RawConfigParser = lambda: parser
|
||||
|
||||
return parser
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue