old_contents: """
  tests
  ~~~~~
  
  :copyright: (c) 2011 DISQUS.
  :license: Apache License 2.0, see LICENSE for more details.
  """
  import unittest2
  
  NOTSET = object()
  
  
  class BaseTest(unittest2.TestCase):
      def setUp(self):
          pass
  
  
  class fixture(object):
      # This is borrowed from werkzeug : http://bytebucket.org/mitsuhiko/werkzeug-main
      """A decorator that converts a function into a lazy property.  The
      function wrapped is called the first time to retrieve the result
      and then that calculated result is used the next time you access
      the value::
  
          class Foo(object):
  
              @cached_property
              def foo(self):
                  # calculate something important here
                  return 42
  
      The class has to have a `__dict__` in order for this property to
      work.
  
      .. versionchanged:: 0.6
         the `writeable` attribute and parameter was deprecated.  If a
         cached property is writeable or not has to be documented now.
         For performance reasons the implementation does not honor the
         writeable setting and will always make the property writeable.
      """
  
      # implementation detail: this property is implemented as non-data
      # descriptor.  non-data descriptors are only invoked if there is
      # no entry with the same name in the instance's __dict__.
      # this allows us to completely get rid of the access function call
      # overhead.  If one choses to invoke __get__ by hand the property
      # will still work as expected because the lookup logic is replicated
      # in __get__ for manual invocation.
  
      def __init__(self, func, name=None, doc=None, writeable=False):
          if writeable:
              from warnings import warn
              warn(DeprecationWarning('the writeable argument to the '
                                      'cached property is a noop since 0.6 '
                                      'because the property is writeable '
                                      'by default for performance reasons'))
  
          self.__name__ = name or func.__name__
          self.__module__ = func.__module__
          self.__doc__ = doc or func.__doc__
          self.func = func
  
      def __get__(self, obj, type=None):
          if obj is None:
              return self
          value = obj.__dict__.get(self.__name__, NOTSET)
          if value is NOTSET:
              value = self.func(obj)
              obj.__dict__[self.__name__] = value
          return value
  
new_contents: """
  tests
  ~~~~~
  
  :copyright: (c) 2011 DISQUS.
  :license: Apache License 2.0, see LICENSE for more details.
  """
  import unittest2
  
  NOTSET = object()
  
  
  class BaseTest(unittest2.TestCase):
      def setUp(self):
          pass
  
  
  class fixture(object):
      """
      >>> class Foo(object):
      >>>     @fixture
      >>>     def foo(self):
      >>>         # calculate something important here
      >>>         return 42
      """
      def __init__(self, func):
          self.__name__ = func.__name__
          self.__module__ = func.__module__
          self.__doc__ = func.__doc__
          self.func = func
  
      def __get__(self, obj, type=None):
          if obj is None:
              return self
          value = obj.__dict__.get(self.__name__, NOTSET)
          if value is NOTSET:
              value = self.func(obj)
              obj.__dict__[self.__name__] = value
          return value
  
subject: Simplify fixture decorator