As addressed in issue #116, we needed a way for clients to communicate to the server when they had completed running a test case and its fixtures. We did this by making a test result with test_method_name run.
This solution makes the code unclear. It forces us to hardcode the string run in a number of places when checking whether a test result is one of these special results signaling that a test case is complete.
The TestResult constructor wants an actual method, which it inspects to determine the method name (and class name, so it must be a method and not a function!). We use TestCase.run for this since it is the method that creates the test result. I tried using a dedicated method with a more descriptive name (test_case_complete) but it didn't work. I gave up because I'm pretty sure @EvanKrall and I went down that road when we started working on this problem.
An improvement would be to add a flag to TestResult to represent this situation. That would be clearer than checking for a specific test_method_name.
A further, more complicated improvement would be to use some other mechanism for communication of doneness between client and server. Using a TestResult forces consumers to check their test results and make sure they are really reporting the results of a test, and not just communicating some internal state.
As addressed in issue #116, we needed a way for clients to communicate to the server when they had completed running a test case and its fixtures. We did this by making a test result with test_method_name
run
.This solution makes the code unclear. It forces us to hardcode the string
run
in a number of places when checking whether a test result is one of these special results signaling that a test case is complete.The TestResult constructor wants an actual method, which it inspects to determine the method name (and class name, so it must be a method and not a function!). We use TestCase.run for this since it is the method that creates the test result. I tried using a dedicated method with a more descriptive name (
test_case_complete
) but it didn't work. I gave up because I'm pretty sure @EvanKrall and I went down that road when we started working on this problem.An improvement would be to add a flag to TestResult to represent this situation. That would be clearer than checking for a specific test_method_name.
A further, more complicated improvement would be to use some other mechanism for communication of doneness between client and server. Using a TestResult forces consumers to check their test results and make sure they are really reporting the results of a test, and not just communicating some internal state.