[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit decc35249d2605644aec5a3ef5bb337cd0d41175
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits