Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22145

Re: bdb.Bdb (Debugger Base Class) / unittest Interaction

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(at': 0.03; 'script,': 0.07; 'unittest': 0.07; 'scripts': 0.09; 'python': 0.09; '__name__': 0.09; 'from:addr:python': 0.09; 'internally': 0.09; 'gui': 0.13; "'__main__':": 0.16; 'debugged': 0.16; 'debugger': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'pdb': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'subject:unittest': 0.16; 'this:': 0.16; 'def': 0.16; 'statement': 0.17; 'wrote:': 0.20; 'looked': 0.21; 'header:In-Reply-To:1': 0.21; '2.7': 0.21; 'prints': 0.23; 'world!': 0.23; 'tests': 0.25; 'least': 0.26; '(which': 0.26; 'script': 0.26; "i'm": 0.27; "i've": 0.27; 'second': 0.27; 'class': 0.28; 'code': 0.29; "skip:' 10": 0.29; 'import': 0.29; 'appreciated.': 0.30; 'ran': 0.30; 'version': 0.31; 'print': 0.31; 'header:User-Agent:1': 0.32; 'to:addr:python-list': 0.32; 'does': 0.33; 'it.': 0.34; 'received:84': 0.34; 'identical': 0.35; 'reply- to:addr:python.org': 0.35; 'test': 0.35; 'uses': 0.35; 'running': 0.35; 'hello,': 0.35; 'but': 0.36; 'skip:b 20': 0.37; 'replaced': 0.37; 'two': 0.37; 'some': 0.37; 'doing': 0.38; 'wrong': 0.38; 'being': 0.39; 'getting': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'subject: (': 0.40; 'help': 0.40; 'fact,': 0.63; 'it)': 0.67; 'plugin': 0.67; 'header:Reply-To:1': 0.70; 'reply-to:no real name:2**0': 0.72; 'difficulties': 0.84; 'subject:Class': 0.84; 'difference.': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=Dp/UCRD+ c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=qePWxsfFzlIA:10 a=NKgaK2e_CI0A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=LVBK8VyydxO18uTu1bIA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Sun, 25 Mar 2012 22:14:28 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: bdb.Bdb (Debugger Base Class) / unittest Interaction
References <CABxKp+nKjJMVMKDZwQcH+CVu-YJukfdhqdP0aA+MaEh0qxyK2A@mail.gmail.com>
In-Reply-To <CABxKp+nKjJMVMKDZwQcH+CVu-YJukfdhqdP0aA+MaEh0qxyK2A@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.972.1332710080.3037.python-list@python.org> (permalink)
Lines 75
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332710080 news.xs4all.nl 6948 [2001:888:2000:d::a6]:51590
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22145

Show key headers only | View raw


On 25/03/2012 21:42, Ami Tavory wrote:
>    Hello,
>
>    I'm having some difficulties with the interaction between bdb.Bdb and
> scripts which contain unittest. Following are two simplified scenarios
> of a GUI debugger Gedit plugin I'm writing based on bdb.Bdb, and a
> script that is being debugged by it.
>
> --Scenario A--
>
>    The script being debugged is foo.py; its content is
> <code>
> print 'Hello, world!'
> </code>
>
>    The "debugger" (a simplified version of it) is
> <code>
> import bdb
>
> g = {}
> g['__name__'] = '__main__'
> g['__file__'] = 'foo.py'
> statement = 'execfile("%s", %s)' % ('foo.py', str(g))
> bdb.Bdb().run(statement)
> </code>
>
> it indeed prints 'Hello, world'.
>
> --Scenario B--
>
>    The script being debugged is bar.py; its content is
> <code>
> import unittest
>
> class test(unittest.TestCase):
>      def test(self):
>          print 'Hello, world!'
>
> def suite():
>      return unittest.TestLoader().loadTestsFromTestCase(test)
>
> if __name__ == '__main__':
>      unittest.main()
> </code>
>
>    The "debugger" is identical to before, but with 'foo.py' replaced by
> 'bar.py'. It does not print 'Hello, world'. In fact, it prints
> <output>
> ----------------------------------------------------------------------
> Ran 0 tests in 0.000s
> </output>
>
>   However:
>
>  1. Running bar.py as a script, indeed prints 'Hello, world'.
>  2. Running pdb (which internally uses bdb.Bdb) on bar.py, also indeed
>     prints 'Hello, world'.
>
>    I've looked at the code of pdb to see what I'm doing wrong (at least
> in the second case), but couldn't find the difference. Help would be
> much appreciated.
>
With Python 2.7 I'm getting this:

<stdout>
Hello, world!
</stdout>

<stderr>
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
</stderr>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: bdb.Bdb (Debugger Base Class) / unittest Interaction MRAB <python@mrabarnett.plus.com> - 2012-03-25 22:14 +0100

csiph-web