Ilya Sandler <ilya.sand...@gmail.com> added the comment:

> Also, can you take a look at how the pdb unittests work and see if you
can come up with a way to unittest the KeyboardInterrupt behavior?

Yes, this is doable. In fact, I already have such tests written (unix only 
though). The tests are assert based but it should not be difficult to convert 
them to unittest. Moreover, I have many more tests for pdb written in the same 
style. 

However, these tests are not easily (and possibly not at all) integratable with 
existing test_pdb.py module. (See below for the problems). So would it be 
acceptable to have these tests as a separate module (test_pdb2.py or some 
such)? (I might also need some help with integrating the module)

Background
----------

Here is the basic problem: testing/debugging a debugger is hard by itself (you 
need to deal with 2 programs at once: the one being debugged and the debugger 
which run intermittently), now throw in doctest and it becomes much harder (as 
everything you do now gets covered by another layer). And now we need to test 
signals and some of the tests will likely be platform specific which makes it 
even worse. 

In contrast, in my tests the snippets of code are written into a tmp file and 
then are fed into debugger, the debugger itself is run as a subprocess. So if a 
test fails, it can be easily rerun under debugger manually and you can  test 
for things like pdb exits and stalls.

Here is a snippet from my pdb tests (just to give an idea how they would look 
like: essentially, send a command to pdb, check the response).


  pdb=PdbTester("pdb_t_hello","""\
  import time
  for i in xrange(100000000):
     time.sleep(0.05)
  """)

  pdb.pdbHandle.stdin.write("c\n")
  time.sleep(0.01)
  #pdb_t_hello running, try to interrupt it
  pdb.pdbHandle.send_signal(signal.SIGINT)
  pdb.waitForPrompt()
  pdb.queryAndMatch("p i", "0")
  pdb.query("n")
  pdb.query("n")
  pdb.queryAndMatch("p i", "1")
  pdb.query("s")
  pdb.query("s")
  pdb.queryAndMatch("p i","2")
  pdb.pdbHandle.stdin.write("c\n")
  time.sleep(0.03)
  pdb.pdbHandle.send_signal(signal.SIGINT)
  pdb.waitForPrompt()
  pdb.queryAndMatch("p i","3")

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7245>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to