diff options
author | Ralph Bean <rbean@redhat.com> | 2013-01-02 22:25:25 -0500 |
---|---|---|
committer | Ralph Bean <rbean@redhat.com> | 2013-01-02 22:25:25 -0500 |
commit | 04dec794d4c0157dae5b0716ae6884189334673b (patch) | |
tree | 81f76988c61d3dfa2eee9be733ebb2949bd3ffb6 | |
parent | 84f747d13b125a8147f369d0e394f1e935b93f2a (diff) | |
download | dogpile-core-04dec794d4c0157dae5b0716ae6884189334673b.tar.gz |
Added single standalone test for background_runner.
-rw-r--r-- | tests/core/test_backgrounding.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/core/test_backgrounding.py b/tests/core/test_backgrounding.py new file mode 100644 index 0000000..7436099 --- /dev/null +++ b/tests/core/test_backgrounding.py @@ -0,0 +1,27 @@ +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() |