Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How can I hide my stack frames in a TestCase subclass?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Manuel Pégourié-Gonnard  
View profile  
 More options Oct 5 2012, 4:50 am
Newsgroups: comp.lang.python
From: Manuel Pégourié-Gonnard <m...@elzevir.fr>
Date: Fri, 5 Oct 2012 10:50:45 +0200 (CEST)
Local: Fri, Oct 5 2012 4:50 am
Subject: Re: How can I hide my stack frames in a TestCase subclass?
Peter Otten scripsit :

> Manuel P gouri -Gonnard wrote:

>> Peter Otten scripsit :

>>> __unittest = True

>> Hum, is it documented somewhere? I can't find it in the doc. Also, I'm
>> curious to know what kind of magic it's using.

> I took advantage of the fact that Python is open source and had a look into
> the source code ;)

Fair enough.

However, there was an implied question in the "documented" part: can
we rely on it? Isn't it considered an implementation detail (names
starting with underscores)?

> $ cd /usr/lib/python2.7/unittest
> $ grep frame *.py -C2
> ...
> result.py-
> result.py-    def _is_relevant_tb_level(self, tb):
> result.py:        return '__unittest' in tb.tb_frame.f_globals
> result.py-
> ...

> $ grep _is_relevant_tb_level *.py -C5
> result.py-
> result.py-    def _exc_info_to_string(self, err, test):
> result.py-        """Converts a sys.exc_info()-style tuple of values into a
> string."""
> result.py-        exctype, value, tb = err
> result.py-        # Skip test runner traceback levels
> result.py:        while tb and self._is_relevant_tb_level(tb):
> result.py-            tb = tb.tb_next
> result.py-
> ...

> And so on. I actually used an editor, not grep -- but you get the idea.

Sure, thanks.

--
Manuel P gouri -Gonnard - http://people.math.jussieu.fr/~mpg/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.