[PATCH 3/3] tests: Properly open/close the file

Mathieu Bridon bochecha at fedoraproject.org
Thu Mar 19 11:09:25 UTC 2015


From: Mathieu Bridon <bochecha at daitauha.fr>

In addition to being just cleaner, this removes the only warning when
running the tests for the pyrpkg.sources module with Python3.

Not that we're anywhere ready to have pyrpkg run with Python3, but any
little step in that direction is a good thing.

Plus it means pyrpkg.sources works fine with both Python2 and Python3!
---
 test/test_sources.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/test_sources.py b/test/test_sources.py
index 576bd2c..747abe2 100644
--- a/test/test_sources.py
+++ b/test/test_sources.py
@@ -102,7 +102,9 @@ class SourcesFileTestCase(unittest.TestCase):
         self.assertEqual(len(s.entries), 0)
 
     def test_open_empty_file(self):
-        open(self.sourcesfile, 'w').write('')
+        with open(self.sourcesfile, 'w') as f:
+            f.write('')
+
         s = sources.SourcesFile(self.sourcesfile, 'bsd')
         self.assertEqual(len(s.entries), 0)
 
-- 
2.1.0



More information about the buildsys mailing list