Closed russelljjarvis closed 7 years ago
@russelljjarvis
There is a setUp
method you can override that will always get called before all the other test_*
methods in the class. You can create some class attributes there that can be written to in your other tests. Perhaps the rheobase test can write the value of e.g. the rheobase current to it (e.g. self.rheobase_value
, and then the other tests can access that value within their test method to parameterize themselves without requiring it to be passed in as an argument.
The only additional requirement would be that the rheobase test execute first. This will happen automatically if it is the test that occurs first in alphabetical order (e.g. test_1_rheobase
vs test_2_input_resistance
). There is some discussion of this here with some people feeling that different tests in a test class shouldn't depend on one another in this way, and others thinking it is OK. I think it is OK.
AOK I have decided to go with the pragmatic but slightly less rigorous approach that you describe, whereby setUp
defines some class attributes that are accessible in subsequent _test methods.
I succeeded in creating a parallel versus serial rheobase test.
Typical output for default param Izhikivitch model is: serial time 292.6495084762573 parallel time 46.785799980163574
sciunit score serial 0.6915871868725569 sciunit score parallel 0.6911871101078924
Actual predictions: serial {'value': array(52.08333333333333) * pA} Lowest suprathreshold current is 52.15 pA Highest subthreshold current is 51.56 pA
Actual predictions: parallel: {'value': array(52.1484375) * pA} 51.56 pA <52.1483375 < 52.15 pA, so the test checks out.
The only problem is the combined wait time of this test is at least 292+46= 338 seconds.
Which is fine. I only want to perform the really long wait function once per program, as opposed to once per function.
As a way to achieve this, I use the outputs from a function that generates these values once to inform more tests.
Ie I want to replace the try catch block here: https://github.com/russelljjarvis/neuronunit/blob/dev/unit_test/neuron_back_end_tests.py#L74-L85 With dedicated tests here: https://github.com/russelljjarvis/neuronunit/blob/dev/unit_test/neuron_back_end_tests.py#L96-L108
The only problem is the def *_test methods are executed by the unittest module, and its unclear how you provide additional arguments to it.