def test_correctly_saves_its_data(self):
     # Run & check
     for markup_text, expected_html_text in self.MARKUP_TEXT_FIELD_TESTS:
         test = TestableModel()
         test.content = markup_text
         test.save()
         assert test.content.rendered == expected_html_text
 def test_correctly_saves_its_data(self):
     # Run & check
     for markup_text, expected_html_text in self.MARKUP_TEXT_FIELD_TESTS:
         test = TestableModel()
         test.content = markup_text
         test.save()
         assert test.content.rendered == expected_html_text
 def test_provides_access_to_the_raw_text_and_to_the_rendered_text(self):
     # Setup
     test = TestableModel()
     test.content = '**hello**'
     test.save()
     field = test._meta.get_field('content')
     markup_content = '**hello world!**'
     markup_content_len = len(markup_content)
     # Run
     test.content.raw = markup_content
     markup_bk = test.content
     test.content = markup_bk
     test.save()
     # Check
     assert field.value_to_string(test) == markup_content
     assert test.content.rendered == '<p><strong>hello world!</strong></p>'
     assert len(test.content) == markup_content_len
     with pytest.raises(AttributeError):
         print(TestableModel.content.rendered)
 def test_can_accept_none_values(self):
     # Setup
     test = TestableModel()
     test.content = None
     # Run
     test.save()
     # Check
     assert test.content is None
     rendered = hasattr(test.content, 'rendered')
     assert not rendered
 def test_provides_access_to_the_raw_text_and_to_the_rendered_text(self):
     # Setup
     test = TestableModel()
     test.content = '**hello**'
     test.save()
     field = test._meta.get_field('content')
     markup_content = '**hello world!**'
     markup_content_len = len(markup_content)
     # Run
     test.content.raw = markup_content
     markup_bk = test.content
     test.content = markup_bk
     test.save()
     # Check
     assert field.value_to_string(test) == markup_content
     assert test.content.rendered == '<p><strong>hello world!</strong></p>'
     assert len(test.content) == markup_content_len
     with pytest.raises(AttributeError):
         print(TestableModel.content.rendered)
 def test_can_accept_none_values(self):
     # Setup
     test = TestableModel()
     test.content = None
     # Run
     test.save()
     # Check
     assert test.content is None
     rendered = hasattr(test.content, 'rendered')
     assert not rendered