Commits

dan mackinlay  committed ced2922 Merge

merge upstream

  • Participants
  • Parent commits 44e3857, 2d1809f

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 setup.py

File contents unchanged.

File 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()