title: How to set up a resource shared by several unit tests?
body: <p>In Python, how can I have one setup (which may contain expensive function calls) for a whole set of unit tests?</p>
  
  <p>Example:</p>
  
  <pre><code>import unittest
  
  class Test1(unittest.TestCase):
      def setUp(self):
          print "expensive call"
      def test1(self):
          self.assertEqual(1, 1)
      def test2(self):
          self.assertEqual(1, 1)
  
  if __name__ == "__main__":
      unittest.main()
  </code></pre>
  
  <p>Will run the expensive call twice:</p>
  
  <pre><code>$ python unittest.py
  expensive call
  .expensive call
  .
  ----------------------------------------------------------------------
  Ran 2 tests in 0.000s
  
  OK
  </code></pre>
  
  <p>How can I change it so the expensive call is made only once and its resources accessible to all tests?</p>
  
  <p>UPDATE: I'm using Python 2.6.</p>