Пример #1
0
 def test_markup_when_empty(self):
     html = HTML()
     with html:
         Head()
         Body()
     self.assertEqual(
         dedent(
             """\
             """
         ),
         html.markup(width=80)
     )
Пример #2
0
 def test_markup_when_first_child_is_script(self):
     html = HTML()
     with html:
         with Head():
             Title('Hello')
         with Body():
             Script(src='foo.js')
     self.assertEqual(
         dedent(
             """\
             <title>Hello</title>
             <body>
                 <script src=foo.js></script>
             """
         ),
         html.markup(width=80)
     )
Пример #3
0
 def test_markup(self):
     html = HTML()
     with html:
         with Head():
             Title('Hello')
         with Body():
             Div()
     self.assertEqual(
         dedent(
             """\
             <title>Hello</title>
             <div>
             </div>
             """
         ),
         html.markup(width=80)
     )
Пример #4
0
 def test_markup_when_followed_by_comment(self):
     html = HTML()
     with html:
         with Head():
             Title('Hello')
         Comment('foobar')
     self.assertEqual(
         dedent(
             """\
             <head>
                 <title>Hello</title>
             </head>
             <!-- foobar -->
             """
         ),
         html.markup(width=80)
     )
Пример #5
0
 def test_markup_when_first_child_is_comment(self):
     html = HTML()
     with html:
         with Head():
             Title('Hello')
         with Body():
             Comment('foobar')
             Div()
     self.assertEqual(
         dedent(
             """\
             <title>Hello</title>
             <body>
                 <!-- foobar -->
                 <div>
                 </div>
             """
         ),
         html.markup(width=80)
     )
Пример #6
0
 def test_markup(self):
     document = Document()
     with document:
         DocType()
         HTML()
         Comment('a comment')
     self.assertEqual(
         dedent("""\
             <!doctype html>
             <html>
             </html>
             <!-- a comment -->
             """), document.markup(width=80))
Пример #7
0
 def test_markup_when_first_child_is_a_comment(self):
     document = Document()
     with document:
         with HTML():
             Comment('foobar')
             with Head():
                 Title('Hello')
             Body()
     self.assertEqual(
         dedent(
             """\
             <html>
             <!-- foobar -->
             <title>Hello</title>
             """
         ),
         document.markup(width=80)
     )