[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-140-g5ccf988

Sandro Tosi morph at debian.org
Thu Dec 2 00:08:00 UTC 2010


The following commit has been merged in the master branch:
commit 8946d28dfe06c8d2076dd60f51f0f4ef4a78610a
Author: Sandro Tosi <morph at debian.org>
Date:   Fri Nov 12 20:12:07 2010 +0100

    almost complete coverage of reportbug.tempfiles

diff --git a/tests/test_tempfiles.py b/tests/test_tempfiles.py
index d984f96..6b693b2 100644
--- a/tests/test_tempfiles.py
+++ b/tests/test_tempfiles.py
@@ -1,6 +1,7 @@
 import unittest2
 
 from reportbug import tempfiles
+import os.path
 
 class TestTempfiles(unittest2.TestCase):
 
@@ -20,3 +21,37 @@ class TestTempfiles(unittest2.TestCase):
         prefix = tempfiles.tempfile_prefix(package='dpkg', extra=extra)
         self.assertIn('dpkg', prefix)
         self.assertIn(extra, prefix)
+
+    def test_open_write_safe(self):
+
+        filename = os.path.dirname(__file__) + '/tempfiletest'
+        # binary file
+        fd = tempfiles.open_write_safe(filename)
+
+        self.assertFalse(fd.closed)
+        fd.close()
+        self.assertTrue(fd.closed)
+
+        # remove temp file
+        tempfiles.cleanup_temp_file(filename)
+
+        filename = os.path.dirname(__file__) + '/tempfiletest'
+        # text file
+        fd = tempfiles.open_write_safe(filename, mode='w')
+
+        self.assertFalse(fd.closed)
+        fd.close()
+        self.assertTrue(fd.closed)
+
+        tempfiles.cleanup_temp_file(filename)
+
+    def test_TempFile(self):
+
+        fd, filename = tempfiles.TempFile()
+
+        self.assertIsNotNone(filename)
+        self.assertFalse(fd.closed)
+        fd.close()
+        self.assertTrue(fd.closed)
+
+        tempfiles.cleanup_temp_file(filename)

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list