for filename in filenames:
logger.debug(" reading %s", filename)
- parser.read(filename)
+ parser.read(filename, encoding='utf-8')
if os.path.split(filename)[-1] == 'setup.cfg':
self._read_setup_cfg(parser, filename)
return
shutil.move(_FILENAME, '%s.old' % _FILENAME)
- with open(_FILENAME, 'w') as fp:
+ with open(_FILENAME, 'w', encoding='utf-8') as fp:
fp.write('[metadata]\n')
# simple string entries
for name in ('name', 'version', 'summary', 'download_url'):
d = tempfile.mkdtemp(dir=self._basetempdir)
return d
- def write_file(self, path, content='xxx'):
+ def write_file(self, path, content='xxx', encoding=None):
"""Write a file at the given path.
path can be a string, a tuple or a list; if it's a tuple or list,
"""
if isinstance(path, (list, tuple)):
path = os.path.join(*path)
- with open(path, 'w') as f:
+ with open(path, 'w', encoding=encoding) as f:
f.write(content)
def create_dist(self, **kw):
def test_convert_setup_py_to_cfg(self):
self.write_file((self.wdir, 'setup.py'),
dedent("""
- # -*- coding: utf-8 -*-
+ # coding: utf-8
from distutils.core import setup
long_description = '''My super Death-scription
},
scripts=['my_script', 'bin/run'],
)
- """))
+ """), encoding='utf-8')
sys.stdin.write('y\n')
sys.stdin.seek(0)
main()
- with open(os.path.join(self.wdir, 'setup.cfg')) as fp:
+ with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp:
lines = set(line.rstrip() for line in fp)
# FIXME don't use sets
def test_convert_setup_py_to_cfg_with_description_in_readme(self):
self.write_file((self.wdir, 'setup.py'),
dedent("""
- # -*- coding: utf-8 -*-
+ # coding: utf-8
from distutils.core import setup
with open('README.txt') as fp:
long_description = fp.read()
('share/man', ['pyxfoil.1']),
],
)
- """))
+ """), encoding='utf-8')
self.write_file((self.wdir, 'README.txt'),
dedent('''
My super Death-scription
sys.stdin.seek(0)
# FIXME Out of memory error.
main()
- with open(os.path.join(self.wdir, 'setup.cfg')) as fp:
+ with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp:
lines = set(line.rstrip() for line in fp)
self.assertEqual(lines, set(['',