Skip to content

Instantly share code, notes, and snippets.

@cgoldberg
Created July 7, 2014 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgoldberg/7b9a90a4a889335dc025 to your computer and use it in GitHub Desktop.
Save cgoldberg/7b9a90a4a889335dc025 to your computer and use it in GitHub Desktop.
testtools - adding test details (content objects) to your tests
#!/usr/bin/env python3
#
# This example adds testtools Details from a testtools TestCase.
#
# For more information about: testtools, Details, and Content Objects, visit:
# * https://testtools.readthedocs.org/en/latest/for-test-authors.html#details
from testtools import TestCase
from testtools.content import (
ContentType,
content_from_file,
text_content,
)
class TestSomething(TestCase):
def test_add_text_detail(self):
self.addDetail('arbitrary-text', text_content('I am a text detail'))
def test_add_image_detail(self):
image = content_from_file('image.jpg', ContentType('image', 'jpg'))
self.addDetail('image.jpg', image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment