Hello testing in python members,<br><br>I need some help related to py.test and unittest. I have tests written and run using unittest and now I also want py.test to be able to run it. The problem is at the beginning of each suite in a test script there is a setup that needs to be done. I need this setup function to be called as well when run with py.test.<br>
<br>To illustrate my problem, I have a test script below and my goal is to be able to run<font face="courier new,monospace"> custom_setup()</font> when run with unittest or py.test. The problem is setup_class is not getting called. We use python 2.6.4 and py-1.2.1. Can this be done? Thank you.<br>
<br>-hans <br><br><span style="font-family: courier new,monospace;">import logging</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import unittest</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">logging.getLogger()</span><br style="font-family: courier new,monospace;"><font face="courier new,monospace"><br>def custom_setup():<br>    </font><span style="font-family: courier new,monospace;"><a href="http://logging.info">logging.info</a>(&#39;custom setup&#39;)</span><br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class TestSimple(unittest.TestCase):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    def setup_class(cls):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        <a href="http://logging.info">logging.info</a>(&#39;setup_class&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        </span><font face="courier new,monospace">custom_setup()</font><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    def setUp(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        <a href="http://logging.info">logging.info</a>(&#39;setUp&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    def test_1(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <a href="http://logging.info">logging.info</a>(&#39;test_1&#39;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    def test_2(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        <a href="http://logging.info">logging.info</a>(&#39;test_2&#39;)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if __name__ == &#39;__main__&#39;:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><font face="courier new,monospace">custom_setup()</font><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    suite = unittest.TestLoader().loadTestsFromTestCase(TestSimple)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    unittest.TextTestRunner(verbosity=2).run(suite)</span><br>