Noob in Python. Problem with fairly simple test case

Chris Angelico rosuav at gmail.com
Wed Jul 15 23:11:28 EDT 2015


On Thu, Jul 16, 2015 at 1:01 PM, Larry Hudson via Python-list
<python-list at python.org> wrote:
> On 07/15/2015 05:11 AM, Chris Angelico wrote:
>>
>> On Wed, Jul 15, 2015 at 9:44 PM, Jason P. <suscricions at gmail.com> wrote:
>>>
>>> I can't understand very well what's happening. It seems that the main
>>> thread gets blocked listening to the web server. My intent was to spawn
>>> another process for the server independent of the test. Obviously I'm doing
>>> something wrong. I've made several guesses commenting pieces of code
>>> (tearDown method for example) but I didn't manage to solve the problem(s).
>>>
>>
>> When you find yourself making guesses to try to figure out what's
>> going on, here are two general tips:
>>
>> 1) Cut out as many pieces as you can. Test one small thing at a time.
>> 2) If In Doubt, Print It Out! Stick print() calls into the code at key
>> places, displaying the values of parameters or the results of
>> intermediate calculations - or just saying "Hi, I'm still here and I'm
>> running!".
>>
> In addition to using print(), in some places I like using input() instead,
> as in:
>     input('x={}, y={} --> '.format(x, y))
> Then the program stops at that point so you can study it.
> To continue just press <Enter>, or Ctrl-C to abort.

That's a neat trick, as long as you actually do have a console. IIDPIO
is extremely general (works across languages, across frameworks (eg a
web server), etc), but these kinds of extensions are pretty handy when
they make sense.

ChrisA



More information about the Python-list mailing list