[Python-Dev] Does trace modules have a unit test?

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Jul 22 19:30:03 CEST 2010


On Wed, Jul 21, 2010 at 9:26 PM, Steve Holden <steve at holdenweb.com> wrote:
> On 7/21/2010 6:45 PM, Alexander Belopolsky wrote:
>> On Wed, Jul 21, 2010 at 1:42 PM, Benjamin Peterson <benjamin at python.org> wrote:
>> ..
>>> True, but the tests in that file are (mostly?) all about line tracing.
>>>
>>
>> Hopefully this will change soon. :-)
>
> At which point the renaming would be justified.

True, but at that point it may be in three or more branches while
right now it is in one.   It turns out, however, that the tests in the
file formerly known as test_trace cover more than line tracing, for
example:

    # Test the handling of exceptions raised by each kind of trace event.
    def test_call(self):
        self.run_test_for_event('call')
    def test_line(self):
        self.run_test_for_event('line')
    def test_return(self):
        self.run_test_for_event('return')
    def test_exception(self):
        self.run_test_for_event('exception')

Furthermore, the now out of date comment in test_sys says:

    # testing sys.settrace() is done in test_trace.py

which makes it clear that the original intent of test_trace was to
test everything settrace does, not just line tracing.

In any case, it looks like my original question got shadowed by the
choice of name discussion.  Is it ok to rename test_trace to
test_whatever in the maintenance branches?   The reason is that the
trace module is severely broken in 3.x and there are no regression
tests in 2.7 to test the 3.x port against.

Another alternative is to simply add trace module tests into
test_trace.  After all, the test_sys comment I mentioned is followed
by

    # testing sys.setprofile() is done in test_profile.py

The profile situation is different, though: test_profile tests the
profile module, but not sys.setprofile() .

Since there is some movement in this area, I don't think it would hurt
to make a decision now that will help writing tests in the future.

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:-).


More information about the Python-Dev mailing list