Skip to content

[pre-commit.ci] pre-commit autoupdate #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 25.1.0
hooks:
- id: black
args: [--line-length=80]
- repo: https://github.com/PyCQA/flake8
rev: "3.8.4"
rev: "7.2.0"
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
rev: v3.19.1
hooks:
- id: pyupgrade
args: [--py36-plus]
60 changes: 30 additions & 30 deletions morepath_wiki/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
self._stack.pop()

def __repr__(self):
return "<HTML {} 0x{:x}>".format(self._name, id(self))
return f"<HTML {self._name} 0x{id(self):x}>"

def _stringify(self, str_type):
# turn me and my content into text
Expand Down Expand Up @@ -424,19 +424,19 @@ def _stringify(self, str_type):
class TestCase(unittest.TestCase):
def test_empty_tag(self):
"generation of an empty HTML tag"
self.assertEquals(str(HTML().br), "<br>")
self.assertEqual(str(HTML().br), "<br>")

def test_empty_tag_xml(self):
"generation of an empty XHTML tag"
self.assertEquals(str(XHTML().br), "<br />")
self.assertEqual(str(XHTML().br), "<br />")

def test_tag_add(self):
"test top-level tag creation"
self.assertEquals(str(HTML("html", "text")), "<html>\ntext\n</html>")
self.assertEqual(str(HTML("html", "text")), "<html>\ntext\n</html>")

def test_tag_add_no_newline(self):
"test top-level tag creation"
self.assertEquals(
self.assertEqual(
str(HTML("html", "text", newlines=False)), "<html>text</html>"
)

Expand All @@ -445,7 +445,7 @@ def test_iadd_tag(self):
h = XML("xml")
h += XML("some-tag", "spam", newlines=False)
h += XML("text", "spam", newlines=False)
self.assertEquals(
self.assertEqual(
str(h),
"<xml>\n<some-tag>spam</some-tag>\n<text>spam</text>\n</xml>",
)
Expand All @@ -455,79 +455,79 @@ def test_iadd_text(self):
h = HTML("html", newlines=False)
h += "text"
h += "text"
self.assertEquals(str(h), "<html>texttext</html>")
self.assertEqual(str(h), "<html>texttext</html>")

def test_xhtml_match_tag(self):
"check forced generation of matching tag when empty"
self.assertEquals(str(XHTML().p), "<p></p>")
self.assertEqual(str(XHTML().p), "<p></p>")

if sys.version_info[0] == 2:

def test_empty_tag_unicode(self):
"generation of an empty HTML tag"
self.assertEquals(unicode(HTML().br), unicode("<br>"))
self.assertEqual(unicode(HTML().br), unicode("<br>"))

def test_empty_tag_xml_unicode(self):
"generation of an empty XHTML tag"
self.assertEquals(unicode(XHTML().br), unicode("<br />"))
self.assertEqual(unicode(XHTML().br), unicode("<br />"))

def test_xhtml_match_tag_unicode(self):
"check forced generation of matching tag when empty"
self.assertEquals(unicode(XHTML().p), unicode("<p></p>"))
self.assertEqual(unicode(XHTML().p), unicode("<p></p>"))

def test_just_tag(self):
"generate HTML for just one tag"
self.assertEquals(str(HTML().br), "<br>")
self.assertEqual(str(HTML().br), "<br>")

def test_just_tag_xhtml(self):
"generate XHTML for just one tag"
self.assertEquals(str(XHTML().br), "<br />")
self.assertEqual(str(XHTML().br), "<br />")

def test_xml(self):
"generate XML"
self.assertEquals(str(XML().br), "<br />")
self.assertEquals(str(XML().p), "<p />")
self.assertEquals(str(XML().br("text")), "<br>text</br>")
self.assertEqual(str(XML().br), "<br />")
self.assertEqual(str(XML().p), "<p />")
self.assertEqual(str(XML().br("text")), "<br>text</br>")

def test_para_tag(self):
"generation of a tag with contents"
h = HTML()
h.p("hello")
self.assertEquals(str(h), "<p>hello</p>")
self.assertEqual(str(h), "<p>hello</p>")

def test_escape(self):
"escaping of special HTML characters in text"
h = HTML()
h.text("<>&")
self.assertEquals(str(h), "&lt;&gt;&amp;")
self.assertEqual(str(h), "&lt;&gt;&amp;")

def test_no_escape(self):
"no escaping of special HTML characters in text"
h = HTML()
h.text("<>&", False)
self.assertEquals(str(h), "<>&")
self.assertEqual(str(h), "<>&")

def test_escape_attr(self):
"escaping of special HTML characters in attributes"
h = HTML()
h.br(id='<>&"')
self.assertEquals(str(h), '<br id="&lt;&gt;&amp;&quot;">')
self.assertEqual(str(h), '<br id="&lt;&gt;&amp;&quot;">')

def test_subtag_context(self):
'generation of sub-tags using "with" context'
h = HTML()
with h.ol:
h.li("foo")
h.li("bar")
self.assertEquals(str(h), "<ol>\n<li>foo</li>\n<li>bar</li>\n</ol>")
self.assertEqual(str(h), "<ol>\n<li>foo</li>\n<li>bar</li>\n</ol>")

def test_subtag_direct(self):
"generation of sub-tags directly on the parent tag"
h = HTML()
l = h.ol
l.li("foo")
l.li.b("bar")
self.assertEquals(
self.assertEqual(
str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>"
)

Expand All @@ -537,7 +537,7 @@ def test_subtag_direct_context(self):
with h.ol as l:
l.li("foo")
l.li.b("bar")
self.assertEquals(
self.assertEqual(
str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>"
)

Expand All @@ -547,35 +547,35 @@ def test_subtag_no_newlines(self):
l = h.ol(newlines=False)
l.li("foo")
l.li("bar")
self.assertEquals(str(h), "<ol><li>foo</li><li>bar</li></ol>")
self.assertEqual(str(h), "<ol><li>foo</li><li>bar</li></ol>")

def test_add_text(self):
"add text to a tag"
h = HTML()
p = h.p("hello, world!\n")
p.text("more text")
self.assertEquals(str(h), "<p>hello, world!\nmore text</p>")
self.assertEqual(str(h), "<p>hello, world!\nmore text</p>")

def test_add_text_newlines(self):
"add text to a tag with newlines for prettiness"
h = HTML()
p = h.p("hello, world!", newlines=True)
p.text("more text")
self.assertEquals(str(h), "<p>\nhello, world!\nmore text\n</p>")
self.assertEqual(str(h), "<p>\nhello, world!\nmore text\n</p>")

def test_doc_newlines(self):
"default document adding newlines between tags"
h = HTML()
h.br
h.br
self.assertEquals(str(h), "<br>\n<br>")
self.assertEqual(str(h), "<br>\n<br>")

def test_doc_no_newlines(self):
"prevent document adding newlines between tags"
h = HTML(newlines=False)
h.br
h.br
self.assertEquals(str(h), "<br><br>")
self.assertEqual(str(h), "<br><br>")

def test_unicode(self):
"make sure unicode input works and results in unicode output"
Expand All @@ -588,7 +588,7 @@ def test_unicode(self):
unicode = str
TEST = "euro €"
h.p(TEST)
self.assertEquals(unicode(h), "<p>%s</p>" % TEST)
self.assertEqual(unicode(h), "<p>%s</p>" % TEST)

def test_table(self):
'multiple "with" context blocks'
Expand All @@ -598,7 +598,7 @@ def test_table(self):
with h.tr:
h.td("column 1")
h.td("column 2")
self.assertEquals(
self.assertEqual(
str(h),
"""<table border="1">
<tr><td>column 1</td><td>column 2</td></tr>
Expand Down