dan mackinlay avatar dan mackinlay committed ced2922 Merge

merge upstream

Comments (0)

Files changed (3)

 def get_tmp_dir():
     import tempfile
     return tempfile.mkdtemp()
+
     
 class FSDict(dict):
     """
     def __setstate__(self, state):
         self.__dict__ = state
         self.work_dir = path(self.work_dir)
+    
+    def setdefault(self, k, d=None):
+        if k not in self:
+            self[k] = d
+        return self[k]
 

File contents unchanged.

tests/fsdict_tests.py

     assert d2 != fsd
     assert d3 != fsd
     assert "foo" != fsd
-    
+    
+def test_fsdict_setdefault():
+    """does setdefault work as expected?"""
+    d = FSDict()
+    yield assert_equal, d.setdefault('a',2), 2
+    #sure, but did that REALLY go to the FS?
+    yield assert_true, (d.work_dir/'a').exists()
+    yield assert_equal, d.setdefault('a',3), 2
+    d.cleanup()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.