moohaad / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Clicking 'Refresh tests' crashes PyScripter #198

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enter 
     import unittest
     unittest.main()
   in an editor window
2. Click 'Refresh tests' Button on the 'Unit Tests' pane.

What is the expected output? What do you see instead?
Expected: MessageBox: 'No tests found'
instead:  PyScripter closes down immediately

What version of the product are you using? On what operating system?
PyScripter 1.9.9.2 on WindowsXP SP2

Original issue reported on code.google.com by rainer.m...@gmail.com on 8 Mar 2008 at 4:13

GoogleCodeExporter commented 9 years ago
I will fix this, but it is common to write this code as

import unittest
if __name__ == '__main__':
    unittest.main()

unittest.main() raises a sys.exit() which is not trapped.

Original comment by pyscripter on 8 Mar 2008 at 4:41

GoogleCodeExporter commented 9 years ago
Fixed in version control.  Module imports now trap SystemExit exceptions 
avoiding
PyScripter closing down in the scenario you described.

Original comment by pyscripter on 9 Mar 2008 at 3:38

GoogleCodeExporter commented 9 years ago
Thanks! That was fast.

So klicking the 'Refresh tests' will still execute the tests, if I omit "if 
__name__
== '__main__':", right? No big deal.

Playing around with unittests, I naively just thought, I could skip the if 
clause,
because nobody would ever import my dumb test module.

Thanks again

   Rainer

Original comment by rainer.m...@gmail.com on 10 Mar 2008 at 5:37

GoogleCodeExporter commented 9 years ago
Tip:  Have you tried the Unit Test Wizard (under Tools)

Original comment by pyscripter on 10 Mar 2008 at 6:42

GoogleCodeExporter commented 9 years ago
Nice!
Thanks for the tip

  Rainer

Original comment by rainer.m...@gmail.com on 11 Mar 2008 at 8:24