Use os.fdopen() on file descriptors returned from mkstemp().
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Feb 2009 04:03:00 +0000 (04:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Feb 2009 04:03:00 +0000 (04:03 -0000)
svn path=/main/trunk/; revision=12725

pym/portage/tests/sets/files/testConfigFileSet.py
pym/portage/tests/sets/files/testStaticFileSet.py

index a7a9645cd505cf73ccf71778ce394f5a7174355c..7ea17fd1bf9de6dc962b069b86d8233e44ffb11c 100644 (file)
@@ -13,8 +13,7 @@ class ConfigFileSetTestCase(TestCase):
 
        def setUp(self):
                fd, self.testfile = tempfile.mkstemp(suffix=".testdata", prefix=self.__class__.__name__, text=True)
-               os.close(fd)
-               f = open(self.testfile, 'w')
+               f = os.fdopen(fd, 'w')
                for i in range(0, len(test_cps)):
                        atom = test_cps[i]
                        if i % 2 == 0:
index 4c7a191b1050c0fa27afca623fb2883fe01f0a7d..fff583da12a9546770c49eae8e39c3aa6559cc13 100644 (file)
@@ -15,8 +15,9 @@ class StaticFileSetTestCase(TestCase):
 
        def setUp(self):
                fd, self.testfile = tempfile.mkstemp(suffix=".testdata", prefix=self.__class__.__name__, text=True)
-               os.close(fd)
-               open(self.testfile, 'w').write("\n".join(test_cps))
+               f = os.fdopen(fd, 'w')
+               f.write("\n".join(test_cps))
+               f.close()
 
        def tearDown(self):
                os.unlink(self.testfile)