def test_css_write_string(): css_string = 'test styles' css = ps.Css(css_string=css_string, name='test name') output = css.write() output_string = output.__str__() assert output_string.startswith('<style type="text/css"') assert output_string.endswith('</style>') assert css_string in output_string
def test_register_interactive_write_interactive(): test_css = ps.Css(css_string='test styles', name='test name') ps.register_interactive(test_css) stream = StringIO() ps.write_interactive(stream) assert 'test styles' in stream.getvalue() # Add once more, should not be in final output more than once ps.register_interactive(test_css) stream = StringIO() ps.write_interactive(stream) assert stream.getvalue().count('test styles') == 1
def test_css_raises_with_no_name_and_string(): with pytest.raises(ValueError): ps.Css()