ini_unit test fix

This commit is contained in:
Ageeleshwar Kandavelu 2015-08-21 14:47:13 +05:30
parent 77bc8fcc55
commit dd48f8ff50
2 changed files with 7 additions and 6 deletions

View File

@ -16,7 +16,7 @@ from __future__ import absolute_import
import re
import json
from salt.utils.odict import OrderedDict
from salt.utils import fopen
from salt.utils import fopen as _fopen
__virtualname__ = 'ini'
@ -303,7 +303,8 @@ class _Section(OrderedDict):
def dump(self):
print(str(self))
def __repr__(self, _repr_running={}):
def __repr__(self, _repr_running=None):
_repr_running = _repr_running or {}
super_repr = super(_Section, self).__repr__(_repr_running)
return '\n'.join((super_repr, json.dumps(self, indent=4)))
@ -324,7 +325,7 @@ class _Ini(_Section):
super(_Ini, self).__init__(name, inicontents, seperator, commenter)
def refresh(self, inicontents=None):
inicontents = inicontents or fopen(self.name).read()
inicontents = inicontents or _fopen(self.name).read()
if not inicontents:
return
for opt in self:
@ -338,7 +339,7 @@ class _Ini(_Section):
self.update({sect_obj.name: sect_obj})
def flush(self):
with fopen(self.name, 'w') as outfile:
with _fopen(self.name, 'w') as outfile:
ini_gen = self.gen_ini()
next(ini_gen)
outfile.writelines(ini_gen)

View File

@ -105,8 +105,8 @@ empty_option=
'test_set_option': {'after': 'test_set_value',
'before': None}
},
'SectionD': {'test_set_option2': {'after': 'test_set_value1',
'before': None}
'SectionD': {'after': {'test_set_option2': 'test_set_value1',
'before': None}
}
})
# Check existing option updated