Commits

Ralph Bean committed dd6bd63

Added single standalone test for background_runner.

  • Participants
  • Parent commits 68cf4e5

Comments (0)

Files changed (1)

tests/core/test_backgrounding.py

+import unittest
+import threading
+import dogpile.core
+
+
+class TestBackgroundRunner(unittest.TestCase):
+    def test_background_release(self):
+        self.called = False
+
+        def runner(mutex, creator):
+            self.called = True
+            mutex.release()
+
+        mutex = threading.Lock()
+        create = lambda: ("value", 1)
+        get = lambda: ("value", 1)
+        expiretime = 1
+
+        assert not self.called
+
+        with dogpile.core.Lock(mutex, create, get, expiretime, runner) as l:
+            assert self.called
+
+        assert self.called
+
+if __name__ == '__main__':
+    unittest.main()