summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-01-29 20:13:47 -0800
committerDavid Lord <davidism@gmail.com>2020-01-29 22:20:44 -0800
commit337a79f8caeff25422b28771e851c140d5d744ac (patch)
tree42bb52efe6a579da35ef8869dc972d56120e9f5d /tests
parent89b18c5949ecb6b67badda90f5e01895eabc6aa3 (diff)
downloadmarkupsafe-337a79f8caeff25422b28771e851c140d5d744ac.tar.gz
apply pyupgrade
Diffstat (limited to 'tests')
-rw-r--r--tests/test_escape.py23
-rw-r--r--tests/test_exception_custom_html.py3
-rw-r--r--tests/test_leak.py5
-rw-r--r--tests/test_markupsafe.py27
4 files changed, 26 insertions, 32 deletions
diff --git a/tests/test_escape.py b/tests/test_escape.py
index 788134a..bf53fac 100644
--- a/tests/test_escape.py
+++ b/tests/test_escape.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import pytest
from markupsafe import Markup
@@ -8,22 +7,22 @@ from markupsafe import Markup
("value", "expect"),
(
# empty
- (u"", u""),
+ ("", ""),
# ascii
- (u"abcd&><'\"efgh", u"abcd&amp;&gt;&lt;&#39;&#34;efgh"),
- (u"&><'\"efgh", u"&amp;&gt;&lt;&#39;&#34;efgh"),
- (u"abcd&><'\"", u"abcd&amp;&gt;&lt;&#39;&#34;"),
+ ("abcd&><'\"efgh", "abcd&amp;&gt;&lt;&#39;&#34;efgh"),
+ ("&><'\"efgh", "&amp;&gt;&lt;&#39;&#34;efgh"),
+ ("abcd&><'\"", "abcd&amp;&gt;&lt;&#39;&#34;"),
# 2 byte
- (u"こんにちは&><'\"こんばんは", u"こんにちは&amp;&gt;&lt;&#39;&#34;こんばんは"),
- (u"&><'\"こんばんは", u"&amp;&gt;&lt;&#39;&#34;こんばんは"),
- (u"こんにちは&><'\"", u"こんにちは&amp;&gt;&lt;&#39;&#34;"),
+ ("こんにちは&><'\"こんばんは", "こんにちは&amp;&gt;&lt;&#39;&#34;こんばんは"),
+ ("&><'\"こんばんは", "&amp;&gt;&lt;&#39;&#34;こんばんは"),
+ ("こんにちは&><'\"", "こんにちは&amp;&gt;&lt;&#39;&#34;"),
# 4 byte
(
- u"\U0001F363\U0001F362&><'\"\U0001F37A xyz",
- u"\U0001F363\U0001F362&amp;&gt;&lt;&#39;&#34;\U0001F37A xyz",
+ "\U0001F363\U0001F362&><'\"\U0001F37A xyz",
+ "\U0001F363\U0001F362&amp;&gt;&lt;&#39;&#34;\U0001F37A xyz",
),
- (u"&><'\"\U0001F37A xyz", u"&amp;&gt;&lt;&#39;&#34;\U0001F37A xyz"),
- (u"\U0001F363\U0001F362&><'\"", u"\U0001F363\U0001F362&amp;&gt;&lt;&#39;&#34;"),
+ ("&><'\"\U0001F37A xyz", "&amp;&gt;&lt;&#39;&#34;\U0001F37A xyz"),
+ ("\U0001F363\U0001F362&><'\"", "\U0001F363\U0001F362&amp;&gt;&lt;&#39;&#34;"),
),
)
def test_escape(escape, value, expect):
diff --git a/tests/test_exception_custom_html.py b/tests/test_exception_custom_html.py
index 5f9ffde..5cf1e8e 100644
--- a/tests/test_exception_custom_html.py
+++ b/tests/test_exception_custom_html.py
@@ -1,10 +1,9 @@
-# -*- coding: utf-8 -*-
import pytest
from markupsafe import escape
-class CustomHtmlThatRaises(object):
+class CustomHtmlThatRaises:
def __html__(self):
raise ValueError(123)
diff --git a/tests/test_leak.py b/tests/test_leak.py
index b36a4ce..5ed906a 100644
--- a/tests/test_leak.py
+++ b/tests/test_leak.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import gc
import sys
@@ -18,8 +17,8 @@ def test_markup_leaks():
for _j in range(1000):
escape("foo")
escape("<foo>")
- escape(u"foo")
- escape(u"<foo>")
+ escape("foo")
+ escape("<foo>")
if hasattr(sys, "pypy_version_info"):
gc.collect()
diff --git a/tests/test_markupsafe.py b/tests/test_markupsafe.py
index b489fa3..c17d1a8 100644
--- a/tests/test_markupsafe.py
+++ b/tests/test_markupsafe.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import pytest
from markupsafe import escape
@@ -36,15 +35,13 @@ def test_type_behavior():
def test_html_interop():
- class Foo(object):
+ class Foo:
def __html__(self):
return "<em>awesome</em>"
- def __unicode__(self):
+ def __str__(self):
return "awesome"
- __str__ = __unicode__
-
assert Markup(Foo()) == "<em>awesome</em>"
result = Markup("<strong>%s</strong>") % Foo()
assert result == "<strong><em>awesome</em></strong>"
@@ -52,17 +49,17 @@ def test_html_interop():
def test_tuple_interpol():
result = Markup("<em>%s:%s</em>") % ("<foo>", "<bar>")
- expect = Markup(u"<em>&lt;foo&gt;:&lt;bar&gt;</em>")
+ expect = Markup("<em>&lt;foo&gt;:&lt;bar&gt;</em>")
assert result == expect
def test_dict_interpol():
result = Markup("<em>%(foo)s</em>") % {"foo": "<foo>"}
- expect = Markup(u"<em>&lt;foo&gt;</em>")
+ expect = Markup("<em>&lt;foo&gt;</em>")
assert result == expect
result = Markup("<em>%(foo)s:%(bar)s</em>") % {"foo": "<foo>", "bar": "<bar>"}
- expect = Markup(u"<em>&lt;foo&gt;:&lt;bar&gt;</em>")
+ expect = Markup("<em>&lt;foo&gt;:&lt;bar&gt;</em>")
assert result == expect
@@ -103,11 +100,11 @@ def test_formatting_empty():
def test_custom_formatting():
- class HasHTMLOnly(object):
+ class HasHTMLOnly:
def __html__(self):
return Markup("<foo>")
- class HasHTMLAndFormat(object):
+ class HasHTMLAndFormat:
def __html__(self):
return Markup("<foo>")
@@ -119,7 +116,7 @@ def test_custom_formatting():
def test_complex_custom_formatting():
- class User(object):
+ class User:
def __init__(self, id, username):
self.id = id
self.username = username
@@ -144,11 +141,11 @@ def test_complex_custom_formatting():
def test_formatting_with_objects():
- class Stringable(object):
+ class Stringable:
def __str__(self):
- return u"строка"
+ return "строка"
- assert Markup("{s}").format(s=Stringable()) == Markup(u"строка")
+ assert Markup("{s}").format(s=Stringable()) == Markup("строка")
def test_all_set():
@@ -161,7 +158,7 @@ def test_all_set():
def test_escape_silent():
assert escape_silent(None) == Markup()
assert escape(None) == Markup(None)
- assert escape_silent("<foo>") == Markup(u"&lt;foo&gt;")
+ assert escape_silent("<foo>") == Markup("&lt;foo&gt;")
def test_splitting():