ceelian/callme — pull request #13 by skudriashev (2013-12-10 22:25:32+00:00)
Title: Tests refactored

I've refactored tests a little bit. Here arguments it was needed:
1. Imports in alphabetical order;
2. Logging configuration moved to the main function to be called only once (no sense to call it for each test);
3. Empty setUp/tearDown removed;
4. As for tests and threads - I faced a problem when I run tests like this:
server = ...
p = Thread(target=server.start)
p.start()

proxy = ...
res = proxy.use_server('fooserver', timeout=0).madd(1, 1)
# let's imagine here something goes wrong and exception is thrown, so
# server.stop() is never called and thread remains active

server.stop()
...
I propose to use try-finally in this case, so we'll make sure server is stopped even if exception was raised:
server = ...
p = Thread(target=server.start)
p.start()

try:
proxy = ...
res = proxy.use_server('fooserver', timeout=0).madd(1, 1)
# let's imagine here something goes wrong and exception is thrown, so
# server.stop() is never called and thread remains active
finally:
server.stop()
...
5. As for threaded cases (like, test_threaded_method_call, etc.) the problem is that assertEqual was called from within thread and even if it failed the whole test-case passes with OK. So, I've changed it, so assertEqual is called from main thread.

Please, take a look on these changes. Hope, you will find them useful!