selfdescribingvalue.py 834 B

123456789101112131415161718192021222324252627
  1. from hamcrest.core.selfdescribing import SelfDescribing
  2. import warnings
  3. __author__ = "Jon Reid"
  4. __copyright__ = "Copyright 2011 hamcrest.org"
  5. __license__ = "BSD, see License.txt"
  6. class SelfDescribingValue(SelfDescribing):
  7. """Wrap any value in a ``SelfDescribingValue`` to satisfy the
  8. :py:class:`~hamcrest.core.selfdescribing.SelfDescribing` interface.
  9. **Deprecated:** No need for this class now that
  10. :py:meth:`~hamcrest.core.description.Description.append_description_of`
  11. handles any type of value.
  12. """
  13. def __init__(self, value):
  14. warnings.warn('SelfDescribingValue no longer needed',
  15. DeprecationWarning)
  16. self.value = value
  17. def describe_to(self, description):
  18. """Generates a description of the value."""
  19. description.append_value(self.value)