def test_whitespace_preservation(self):
     # p tag with simple string preserves whitespace on the ends
     self.assertEqual(simple_html_renderer("<p>Hello World </p>"),
                      "Hello World ")
     # newlines should be preserved?
     self.assertEqual(simple_html_renderer("<p>Hello \n World</p>"),
                      "Hello \n World")
 def test_inner_style_tag_takes_priority(self):
     # EXPECTED OUTPUT:
     # Hi
     self.assertEqual(
         simple_html_renderer(
             "<style>p{width:6;}</style><p><style>p{width:10;}</style>Hi</p>"
         ), "Hi        \n")
     # EXPECTED OUTPUT:
     # Hello
     # Hi
     self.assertEqual(
         simple_html_renderer(
             "<style>p{width:6;}</style><p>Hello<style>p{width:10;margin-top:4;}</style>Hi</p>"
         ), "Hello \n\n\n\n\nHi      ")
    def test_invalid_style_tag(self):
        with self.assertRaises(SyntaxError):
            # nonexistent tag type
            simple_html_renderer("<style>q{width:7;}</style>")

        with self.assertRaises(SyntaxError):
            # no { to indicate beginning of styling
            simple_html_renderer("<style>p</style>")

        with self.assertRaises(SyntaxError):
            # } delimiter indicates closing of styling
            simple_html_renderer("<style>p{</style>")

        with self.assertRaises(SyntaxError):
            # no actual content after :
            simple_html_renderer("<style>p{width:}</style>")

        with self.assertRaises(SyntaxError):
            # ; delimiter indicates the end
            simple_html_renderer("<style>p{width:10}</style>")
 def test_simple_style_tag_applied_p_tag(self):
     # EXPECTED OUTPUT:
     # Hi
     self.assertEqual(
         simple_html_renderer("<style>p{width:6;}</style><p>Hi</p>"),
         "Hi    \n")
     # EXPECTED OUTPUT:
     # Hi
     #
     #
     #
     #
     #
     self.assertEqual(
         simple_html_renderer("<style>p{height:6;}</style><p>Hi</p>"),
         "Hi\n  \n  \n  \n  \n  ")
     # EXPECTED OUTPUT:
     # Hi
     self.assertEqual(
         simple_html_renderer("<style>p{margin-right:6;}</style><p>Hi</p>"),
         "Hi      \n")
     # EXPECTED OUTPUT:
     #       Hi
     self.assertEqual(
         simple_html_renderer("<style>p{margin-left:6;}</style><p>Hi</p>"),
         "      Hi\n")
     # EXPECTED OUTPUT:
     #
     #
     #
     #
     #
     #
     # Hi
     self.assertEqual(
         simple_html_renderer("<style>p{margin-top:6;}</style><p>Hi</p>"),
         "  \n  \n  \n  \n  \n  \nHi")
     # EXPECTED OUTPUT:
     # Hi
     #
     #
     #
     #
     #
     #
     self.assertEqual(
         simple_html_renderer(
             "<style>p{margin-bottom:6;}</style><p>Hi</p>"),
         "Hi\n  \n  \n  \n  \n  \n  ")
 def test_empty_tags(self):
     self.assertEqual(simple_html_renderer("<p></p>"), "")
     self.assertEqual(simple_html_renderer("<table></table>"), "")
     self.assertEqual(simple_html_renderer("<td></td>"), "")
     self.assertEqual(simple_html_renderer("<tr></tr>"), "")
     self.assertEqual(simple_html_renderer("<style></style>"), "")
 def test_empty_string(self):
     self.assertEqual(simple_html_renderer(""), "")
 def test_tags_with_simple_strings(self):
     self.assertEqual(simple_html_renderer("<p>Hello World!</p>"),
                      "Hello World!")
 def test_missing_end_tags(self):
     with self.assertRaises(SyntaxError):
         simple_html_renderer("<p>")
     with self.assertRaises(SyntaxError):
         simple_html_renderer("<p></table>")