def test_content_returns_the_raw_value_when_converted_to_a_string(self): # Setup test = DummyModel() test.content = '**hello world!**' test.save() # Run & check assert force_text(test.content) == '**hello world!**'
def test_correctly_saves_its_data(self): # Run & check for markup_text, expected_html_text in self.MARKUP_TEXT_FIELD_TESTS: test = DummyModel() test.content = markup_text test.save() assert test.content.rendered.rstrip() == expected_html_text
def test_can_accept_none_values(self): # Setup test = DummyModel() 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 = DummyModel() 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.rstrip() == '<p><strong>hello world!</strong></p>' assert len(test.content) == markup_content_len with pytest.raises(AttributeError): print(DummyModel.content.rendered)