[tor-commits] [stem/master] Test accidently left around a file in /tmp

atagar at torproject.org atagar at torproject.org
Tue Mar 19 01:43:44 UTC 2013


commit decc35249d2605644aec5a3ef5bb337cd0d41175
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Mar 18 18:40:13 2013 -0700

    Test accidently left around a file in /tmp
    
    The test_save_processed_files_malformed checks that save_processed_files()
    fails when presented with malformed data. However, this function still writes
    out a blank file. I noticed this because I just tried running the tests as a
    different user from prior test runs, causing...
    
    ======================================================================
    ERROR: test_save_processed_files_malformed
    ----------------------------------------------------------------------
    Traceback:
      File "/home/atagar/Desktop/stem/test/integ/descriptor/reader.py", line 172, in test_save_processed_files_malformed
        self.assertRaises(TypeError, stem.descriptor.reader.save_processed_files, "/tmp/foo", listing)
      File "/usr/lib/python2.7/unittest/case.py", line 465, in assertRaises
        callableObj(*args, **kwargs)
      File "/home/atagar/Desktop/stem/stem/descriptor/reader.py", line 229, in save_processed_files
        with open(path, "w") as output_file:
    IOError: [Errno 13] Permission denied: '/tmp/foo'
    
    ----------------------------------------------------------------------
    Ran 21 tests in 1.558s
---
 test/integ/descriptor/reader.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index 4f92343..39170a0 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -171,6 +171,14 @@ class TestDescriptorReader(unittest.TestCase):
     for listing in (missing_filename, relative_filename, string_timestamp):
       self.assertRaises(TypeError, stem.descriptor.reader.save_processed_files, "/tmp/foo", listing)
 
+    # Though our attempts to save the processed files fail we'll write an empty
+    # file. Cleaning it up.
+
+    try:
+      os.remove("/tmp/foo")
+    except:
+      pass
+
   def test_basic_example(self):
     """
     Exercises something similar to the first example in the header



More information about the tor-commits mailing list