title: How to accumulate state across tests in py.test
body: <p>I currently have a project and tests similar to these.</p>
  
  <pre><code>class mylib:
      @classmethod
      def get_a(cls):
          return 'a'
  
      @classmethod
      def convert_a_to_b(cls, a):
          return 'b'
  
      @classmethod
      def works_with(cls, a, b):
          return True
  
  class TestMyStuff(object):
      def test_first(self):
          self.a = mylib.get_a()
  
      def test_conversion(self):
          self.b = mylib.convert_a_to_b(self.a)
  
      def test_a_works_with_b(self):
          assert mylib.works_with(self.a, self.b)
  </code></pre>
  
  <p>With py.test 0.9.2, these tests (or similar ones) pass. With later versions of py.test, test_conversion and test_a_works_with_b fail with 'TestMyStuff has no attribute a'.</p>
  
  <p>I am guessing this is because with later builds of py.test, a separate instance of TestMyStuff is created for each method that is tested.</p>
  
  <p>What is the proper way to write these tests such that results can be given for each of the steps in the sequence, but the state from a previous (successful) test can (must) be used to perform subsequent tests?</p>