#1304 setUpClass and tearDown class not called for unit-tests

closed-invalid
nobody
None
5
2011-04-07
2011-04-06
Steven T. Snyder
No

Environment: Pydev 2.0.0.2011040403, Eclipse Helios SR2 20110301-1815, Python 2.7.1, Windows 7 Pro 64-bit

When running a script as a 'Python unit-test' from Pydev, the setUpClass() and tearDownClass() methods (see: http://docs.python.org/library/unittest.html#unittest.TestCase.setUpClass\) are not called on the TestCase instance.

If the script executes the tests when run using 'Python Run' the setUpClass() and tearDownClass() methods are called correctly. When run with 'Python Coverage' it seems to work properly as well.

Example code attached. When run as 'Python unit-test' observe the output:
setUp
test_1
tearDown
setUp
test_2
tearDown

When run with 'Python Run' the output is:
setUpClass
setUp
tearDown
setUp
test_2
tearDown
tearDownClass

Discussion

  • Script file containing tests which produce different output depending on if it's run as 'Python unit-test' or 'Python Run'

     
    Attachments
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-04-07

    Fixed for 2.0.1 (you should be able to get it from the nightly in some hours)

    Git
    da16010 1302193351 2011-04-07

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-04-07

    • status: open --> pending
     
  • Wow, that was quick! Thanks.

    I also found that setUpModule() and tearDownModule() similarly do not run in 2.0.0 in the 'Python unit-test' run configuration. Is this fixed in 2.0.1 as well?

     
    • status: pending --> open
     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-04-07

    Should be... the nightly is already published, so, you can already get it and test it :)

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-04-07

    • status: open --> closed-invalid
     
  • I have verified that this issue has been resolved in 2.0.1.2011040716.