[Python-Dev] Does trace modules have a unit test?
Alexander Belopolsky
alexander.belopolsky at gmail.com
Sat Jul 24 18:20:03 CEST 2010
On Thu, Jul 22, 2010 at 6:33 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Fri, Jul 23, 2010 at 3:30 AM, Alexander Belopolsky
> <alexander.belopolsky at gmail.com> wrote:
>> I see three solutions:
>>
>> 1. Minimal: do not rename test_trace in 2.7 and add trace module
>> tests to the existing file. Whether to revert test_trace to
>> test_line_tracing renaming in 3.2 can be decided after we have 2.7
>> tests written.
>> 2. Rename test_trace in 2.7/3.1 and test_line_tracing in 3.2 to
>> test_sys_settrace.
>> 3. Rename test_trace in 2.7/3.1 to test_line_tracing.
>>
>> My preference in #2, but I can live with #1 (assuming Eli is the one
>> who will write the tests:-).
>
> I'd say just fix it and go with #2 (just update the comment in
> test_sys as well!)
I have looked further into setprofile tests for inspiration and
discovered that it is covered in test_profilehooks. Note that
sys.settrace and sys.setprofile are very similar. They take a
function with the same signature and report events in the same format.
The only difference is in the kind of events that get reported. I
made an experiment replacing [sg]etprofile with [sg]ettrace in
test-profilehooks and all tests worked reporting failures in comparing
outputs.
I would like to use this opportunity to merge settrace and setprofile
tests. Here is the proposal:
Step 1: Rename test_trace to test_sys_settrace and test_profilehooks
to test_sys_setprofile.
Step 2: Create tracetester helper file with abstract test cases made
from the union of test_sys_settrace and test_sys_setprofile test
cases and replace the concrete test cases in test_sys_set* with
subclasses that define setmethod, getmethod and expected_output.
An alternative proposal is to put all tests for both trace and profile
into a single test_sys_tracing file.
What do you think?
(Another option is to leave test_profilehooks and use rename
test_trace to test_tracehooks in the step 1 above.)
More information about the Python-Dev
mailing list