diff options
author | David Lord <davidism@gmail.com> | 2020-01-29 20:13:47 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-01-29 22:20:44 -0800 |
commit | 337a79f8caeff25422b28771e851c140d5d744ac (patch) | |
tree | 42bb52efe6a579da35ef8869dc972d56120e9f5d /tests | |
parent | 89b18c5949ecb6b67badda90f5e01895eabc6aa3 (diff) | |
download | markupsafe-337a79f8caeff25422b28771e851c140d5d744ac.tar.gz |
apply pyupgrade
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_escape.py | 23 | ||||
-rw-r--r-- | tests/test_exception_custom_html.py | 3 | ||||
-rw-r--r-- | tests/test_leak.py | 5 | ||||
-rw-r--r-- | tests/test_markupsafe.py | 27 |
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&><'"efgh"), - (u"&><'\"efgh", u"&><'"efgh"), - (u"abcd&><'\"", u"abcd&><'""), + ("abcd&><'\"efgh", "abcd&><'"efgh"), + ("&><'\"efgh", "&><'"efgh"), + ("abcd&><'\"", "abcd&><'""), # 2 byte - (u"こんにちは&><'\"こんばんは", u"こんにちは&><'"こんばんは"), - (u"&><'\"こんばんは", u"&><'"こんばんは"), - (u"こんにちは&><'\"", u"こんにちは&><'""), + ("こんにちは&><'\"こんばんは", "こんにちは&><'"こんばんは"), + ("&><'\"こんばんは", "&><'"こんばんは"), + ("こんにちは&><'\"", "こんにちは&><'""), # 4 byte ( - u"\U0001F363\U0001F362&><'\"\U0001F37A xyz", - u"\U0001F363\U0001F362&><'"\U0001F37A xyz", + "\U0001F363\U0001F362&><'\"\U0001F37A xyz", + "\U0001F363\U0001F362&><'"\U0001F37A xyz", ), - (u"&><'\"\U0001F37A xyz", u"&><'"\U0001F37A xyz"), - (u"\U0001F363\U0001F362&><'\"", u"\U0001F363\U0001F362&><'""), + ("&><'\"\U0001F37A xyz", "&><'"\U0001F37A xyz"), + ("\U0001F363\U0001F362&><'\"", "\U0001F363\U0001F362&><'""), ), ) 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><foo>:<bar></em>") + expect = Markup("<em><foo>:<bar></em>") assert result == expect def test_dict_interpol(): result = Markup("<em>%(foo)s</em>") % {"foo": "<foo>"} - expect = Markup(u"<em><foo></em>") + expect = Markup("<em><foo></em>") assert result == expect result = Markup("<em>%(foo)s:%(bar)s</em>") % {"foo": "<foo>", "bar": "<bar>"} - expect = Markup(u"<em><foo>:<bar></em>") + expect = Markup("<em><foo>:<bar></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"<foo>") + assert escape_silent("<foo>") == Markup("<foo>") def test_splitting(): |