diff options
Diffstat (limited to 'distutils2/tests/test_command_sdist.py')
| -rw-r--r-- | distutils2/tests/test_command_sdist.py | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py index c056881..9bf1fcf 100644 --- a/distutils2/tests/test_command_sdist.py +++ b/distutils2/tests/test_command_sdist.py @@ -214,11 +214,8 @@ class SDistTestCase(support.TempdirManager, self.assertEqual(len(content), 10) # Checking the MANIFEST - fp = open(join(self.tmp_dir, 'MANIFEST')) - try: + with open(join(self.tmp_dir, 'MANIFEST')) as fp: manifest = fp.read() - finally: - fp.close() self.assertEqual(manifest, MANIFEST % {'sep': os.sep}) @requires_zlib @@ -334,12 +331,9 @@ class SDistTestCase(support.TempdirManager, # Should produce four lines. Those lines are one comment, one default # (README) and two package files. - f = open(cmd.manifest) - try: + with open(cmd.manifest) as f: manifest = [line.strip() for line in f.read().split('\n') if line.strip() != ''] - finally: - f.close() self.assertEqual(len(manifest), 3) # Adding a file @@ -352,12 +346,9 @@ class SDistTestCase(support.TempdirManager, cmd.run() - f = open(cmd.manifest) - try: + with open(cmd.manifest) as f: manifest2 = [line.strip() for line in f.read().split('\n') if line.strip() != ''] - finally: - f.close() # Do we have the new file in MANIFEST? self.assertEqual(len(manifest2), 4) @@ -370,12 +361,9 @@ class SDistTestCase(support.TempdirManager, cmd.ensure_finalized() cmd.run() - f = open(cmd.manifest) - try: + with open(cmd.manifest) as f: manifest = [line.strip() for line in f.read().split('\n') if line.strip() != ''] - finally: - f.close() self.assertEqual(manifest[0], '# file GENERATED by distutils2, do NOT edit') @@ -388,12 +376,9 @@ class SDistTestCase(support.TempdirManager, self.write_file((self.tmp_dir, cmd.manifest), 'README.manual') cmd.run() - f = open(cmd.manifest) - try: + with open(cmd.manifest) as f: manifest = [line.strip() for line in f.read().split('\n') if line.strip() != ''] - finally: - f.close() self.assertEqual(manifest, ['README.manual']) @@ -404,11 +389,8 @@ class SDistTestCase(support.TempdirManager, cmd.ensure_finalized() self.write_file((self.tmp_dir, 'yeah'), 'xxx') cmd.run() - f = open(cmd.manifest) - try: + with open(cmd.manifest) as f: content = f.read() - finally: - f.close() self.assertIn('yeah', content) |
