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

[tor-commits] [stem/master] Don't hardcode /tmp/foo as a test path



commit 2644ec5ab18ae24d4bc0480c98444483dccc7ab9
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Feb 9 07:53:12 2015 -0800

    Don't hardcode /tmp/foo as a test path
    
    Turns out I make foo test paths a lot. Running 'mkdir /tmp/foo' for something
    else broke the unit tests for me. Easy enough to do the proper thing and pick a
    random unused path.
---
 test/unit/descriptor/reader.py |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py
index a699af2..debb88a 100644
--- a/test/unit/descriptor/reader.py
+++ b/test/unit/descriptor/reader.py
@@ -232,15 +232,16 @@ class TestDescriptorReader(unittest.TestCase):
     missing_filename = {'': 123}
     relative_filename = {'foobar': 123}
     string_timestamp = {'/tmp': '123a'}
+    temp_path = tempfile.mkstemp(prefix = 'stem-unit-tests-', text = True)[1]
 
     for listing in (missing_filename, relative_filename, string_timestamp):
-      self.assertRaises(TypeError, stem.descriptor.reader.save_processed_files, '/tmp/foo', listing)
+      self.assertRaises(TypeError, stem.descriptor.reader.save_processed_files, temp_path, listing)
 
     # Though our attempts to save the processed files fail we'll write an empty
     # file. Cleaning it up.
 
     try:
-      os.remove('/tmp/foo')
+      os.remove(temp_path)
     except:
       pass
 



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