summaryrefslogtreecommitdiff
path: root/test/git/async/test_thread.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-05 20:03:09 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-05 20:03:09 +0200
commitab59f78341f1dd188aaf4c30526f6295c63438b1 (patch)
tree697bc8a11201494d560f1ea65fd77b7ef09b238e /test/git/async/test_thread.py
parent61138f2ece0cb864b933698174315c34a78835d1 (diff)
downloadgitpython-ab59f78341f1dd188aaf4c30526f6295c63438b1.tar.gz
Renamed mp to async, as this is a much better name for what is actually going on. The default implementation uses threads, which ends up being nothing more than async, as they are all locked down by internal and the global interpreter lock
Diffstat (limited to 'test/git/async/test_thread.py')
-rw-r--r--test/git/async/test_thread.py47
1 files changed, 47 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..ca306cc0
--- /dev/null
+++ b/test/git/async/test_thread.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+""" Test thead classes and functions"""
+from test.testlib import *
+from git.async.thread import *
+from Queue import Queue
+
+class TestWorker(WorkerThread):
+ def __init__(self, *args, **kwargs):
+ super(TestWorker, self).__init__(*args, **kwargs)
+ self.reset()
+
+ def fun(self, *args, **kwargs):
+ self.called = True
+ self.args = args
+ self.kwargs = kwargs
+ return True
+
+ def make_assertion(self):
+ assert self.called
+ assert self.args
+ assert self.kwargs
+ self.reset()
+
+ def reset(self):
+ self.called = False
+ self.args = None
+ self.kwargs = 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 ("fun", TestWorker.fun, worker.fun, standalone_func):
+ rval = worker.call(function, 1, this='that')
+ assert isinstance(rval, Queue)
+ assert rval.get() is True
+ worker.make_assertion()
+ # END for each function type
+
+ worker.call('quit')
+