<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">On Wed, Apr 14, 2010 at 11:47 AM, john maclean <span dir="ltr"><<a href="mailto:jayeola@gmail.com">jayeola@gmail.com</a>></span>
 wrote:<br>Can
 one use the setUp block to store variables so that they can be<br>
used elsewhere in unit tests? I'm thinking that it's better to have<br>
variables created in another script and have it imported from within<br>
the unit test<br></blockquote><br>Hi John,<br>each TestCase is a object, and you can "store" attributes in this objects normally, using self :)<br><br>class TestPythonStringsTestCase(<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

unittest.TestCase):<br>
        def setUp(self):<br>
                print '''setting up stuff for ''', __name__<br>
                <b>self.</b>s1 = 'single string'<br>
                print dir(str)<br>
<br>
        def testclass(self):<br>
                '''test strings are of class str'''<br>
                self.assertEqual(<b>self.</b>s1.__class__, str)<br>
<br>
if __name__ == "__main__":<br>
        unittest.main()</blockquote><br>This works fine and s1 is an internal attribute of your TesteCase.<br><br>Best regards,<br clear="all">Francisco Souza<br>Software developer at Giran and also full time<br>Open source evangelist at full time<br>

<br><a href="http://www.franciscosouza.net">http://www.franciscosouza.net</a><br>Twitter: @franciscosouza<br>(27) 8128 0652<br>