Commits

dan mackinlay  committed b263c68

added tests to catch setdefault weirdness, although the code to fix it seems not to be necessary. version dependent?

  • Participants
  • Parent commits 5bf40ee

Comments (0)

Files changed (2)

 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 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
+    yield assert_equal, d.setdefault('a',3), 2
+    d.cleanup()