summaryrefslogtreecommitdiff
path: root/test/git/async/test_thread.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-12 12:41:20 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-12 12:41:20 +0200
commitf91495e271597034226f1b9651345091083172c4 (patch)
treee0e2aa63b7dc649083858366eaedb6ac4cc5739b /test/git/async/test_thread.py
parent7c1169f6ea406fec1e26e99821e18e66437e65eb (diff)
parent7a0b79ee574999ecbc76696506352e4a5a0d7159 (diff)
downloadgitpython-f91495e271597034226f1b9651345091083172c4.tar.gz
Merge branch 'async'
Diffstat (limited to 'test/git/async/test_thread.py')
-rw-r--r--test/git/async/test_thread.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/git/async/test_thread.py b/test/git/async/test_thread.py
new file mode 100644
index 00000000..a08c1dc7
--- /dev/null
+++ b/test/git/async/test_thread.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+""" Test thead classes and functions"""
+from test.testlib import *
+from git.async.thread import *
+from Queue import Queue
+import time
+
+class TestWorker(WorkerThread):
+ def __init__(self, *args, **kwargs):
+ super(TestWorker, self).__init__(*args, **kwargs)
+ self.reset()
+
+ def fun(self, arg):
+ self.called = True
+ self.arg = arg
+ return True
+
+ def make_assertion(self):
+ assert self.called
+ assert self.arg
+ self.reset()
+
+ def reset(self):
+ self.called = False
+ self.arg = None
+
+
+class TestThreads( TestCase ):
+
+ @terminate_threads
+ def test_worker_thread(self):
+ worker = TestWorker()
+ assert isinstance(worker.start(), WorkerThread)
+
+ # test different method types
+ standalone_func = lambda *args, **kwargs: worker.fun(*args, **kwargs)
+ for function in (TestWorker.fun, worker.fun, standalone_func):
+ worker.inq.put((function, 1))
+ time.sleep(0.01)
+ worker.make_assertion()
+ # END for each function type
+
+ worker.stop_and_join()
+