diff options
Diffstat (limited to 'distutils2/tests/test_create.py')
| -rw-r--r-- | distutils2/tests/test_create.py | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/distutils2/tests/test_create.py b/distutils2/tests/test_create.py index a268c4f..7a0aa0d 100644 --- a/distutils2/tests/test_create.py +++ b/distutils2/tests/test_create.py @@ -1,9 +1,7 @@ -# encoding: utf-8 """Tests for distutils2.create.""" import os import sys -import codecs -from StringIO import StringIO +from io import StringIO from textwrap import dedent from distutils2.create import MainProgram, ask_yn, ask, main from distutils2._backport import sysconfig @@ -98,7 +96,7 @@ class CreateTestCase(support.TempdirManager, def test_convert_setup_py_to_cfg(self): self.write_file((self.wdir, 'setup.py'), - dedent(u""" + dedent(""" # coding: utf-8 from distutils.core import setup @@ -133,18 +131,15 @@ class CreateTestCase(support.TempdirManager, scripts=['my_script', 'bin/run'], ) """), encoding='utf-8') - sys.stdin.write(u'y\n') + sys.stdin.write('y\n') sys.stdin.seek(0) main() path = os.path.join(self.wdir, 'setup.cfg') - fp = codecs.open(path, encoding='utf-8') - try: + with open(path, encoding='utf-8') as fp: contents = fp.read() - finally: - fp.close() - self.assertEqual(contents, dedent(u"""\ + self.assertEqual(contents, dedent("""\ [metadata] name = pyxfoil version = 0.2 @@ -184,14 +179,11 @@ class CreateTestCase(support.TempdirManager, def test_convert_setup_py_to_cfg_with_description_in_readme(self): self.write_file((self.wdir, 'setup.py'), - dedent(u""" + dedent(""" # coding: utf-8 from distutils.core import setup - fp = open('README.txt') - try: + with open('README.txt') as fp: long_description = fp.read() - finally: - fp.close() setup(name='pyxfoil', version='0.2', @@ -221,13 +213,10 @@ ho, baby! main() path = os.path.join(self.wdir, 'setup.cfg') - fp = codecs.open(path, encoding='utf-8') - try: + with open(path, encoding='utf-8') as fp: contents = fp.read() - finally: - fp.close() - self.assertEqual(contents, dedent(u"""\ + self.assertEqual(contents, dedent("""\ [metadata] name = pyxfoil version = 0.2 |
