From 0c5700be0f8747ed138ebd1cb3c8bcaf4dd3d64c Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Wed, 14 Nov 2018 23:25:51 -0700 Subject: Goodbye compat.PY2 lines --- tests/performance_test.py | 6 +----- tests/test_cookies.py | 26 -------------------------- tests/test_misc.py | 14 +++----------- tests/test_multidict.py | 7 ------- 4 files changed, 4 insertions(+), 49 deletions(-) (limited to 'tests') diff --git a/tests/performance_test.py b/tests/performance_test.py index 4c4917f..9b4397b 100644 --- a/tests/performance_test.py +++ b/tests/performance_test.py @@ -1,6 +1,5 @@ #!/usr/bin/env python from webob.response import Response -from webob.compat import PY2 def make_middleware(app): @@ -43,10 +42,7 @@ if __name__ == "__main__": print("Hit ^C to end") try: while 1: - if PY2: - raw_input() # noqa: F821 - else: - input() + input() finally: os.kill(proc.pid, signal.SIGKILL) else: diff --git a/tests/test_cookies.py b/tests/test_cookies.py index 578bfb8..6f62eb0 100644 --- a/tests/test_cookies.py +++ b/tests/test_cookies.py @@ -6,9 +6,6 @@ from webob import cookies from webob.compat import text_ from webob.compat import native_ -py2only = pytest.mark.skipif("sys.version_info >= (3, 0)") -py3only = pytest.mark.skipif("sys.version_info < (3, 0)") - def setup_module(module): cookies._should_raise = True @@ -407,40 +404,17 @@ class TestRequestCookies(object): inst = self._makeOne(environ) assert sorted(list(inst.items())) == [("a", "1"), ("b", val), ("c", "3")] - @py2only - def test_iterkeys(self): - environ = {"HTTP_COOKIE": 'a=1; b="La Pe\\303\\261a"; c=3'} - inst = self._makeOne(environ) - assert sorted(list(inst.iterkeys())) == ["a", "b", "c"] - - @py3only def test_iterkeys_py3(self): environ = {"HTTP_COOKIE": b'a=1; b="La Pe\\303\\261a"; c=3'.decode("utf-8")} inst = self._makeOne(environ) assert sorted(list(inst.keys())) == ["a", "b", "c"] - @py2only - def test_itervalues(self): - val = text_(b"La Pe\xc3\xb1a", "utf-8") - environ = {"HTTP_COOKIE": 'a=1; b="La Pe\\303\\261a"; c=3'} - inst = self._makeOne(environ) - sorted(list(inst.itervalues())) == ["1", "3", val] - - @py3only def test_itervalues_py3(self): val = text_(b"La Pe\xc3\xb1a", "utf-8") environ = {"HTTP_COOKIE": b'a=1; b="La Pe\\303\\261a"; c=3'.decode("utf-8")} inst = self._makeOne(environ) sorted(list(inst.values())) == ["1", "3", val] - @py2only - def test_iteritems(self): - val = text_(b"La Pe\xc3\xb1a", "utf-8") - environ = {"HTTP_COOKIE": 'a=1; b="La Pe\\303\\261a"; c=3'} - inst = self._makeOne(environ) - assert sorted(list(inst.iteritems())) == [("a", "1"), ("b", val), ("c", "3")] - - @py3only def test_iteritems_py3(self): val = text_(b"La Pe\xc3\xb1a", "utf-8") environ = {"HTTP_COOKIE": b'a=1; b="La Pe\\303\\261a"; c=3'.decode("utf-8")} diff --git a/tests/test_misc.py b/tests/test_misc.py index 1b6c629..42d0479 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,10 +1,6 @@ import pytest - -from webob.util import html_escape from webob.compat import text_ - -py2only = pytest.mark.skipif("sys.version_info >= (3, 0)") -py3only = pytest.mark.skipif("sys.version_info < (3, 0)") +from webob.util import html_escape class t_esc_HTML(object): @@ -43,8 +39,7 @@ class t_esc_SuperMoose(object): ("è", "&egrave;"), # The apostrophe is *not* escaped, which some might consider to be # a serious bug (see, e.g. http://www.cvedetails.com/cve/CVE-2010-2480/) - pytest.param("'", "'", marks=py2only), - pytest.param("'", "'", marks=py3only), + pytest.param("'", "'"), (text_("the majestic m\xf8ose"), "the majestic møose"), # 8-bit strings are passed through (text_("\xe9"), "é"), @@ -59,10 +54,7 @@ class t_esc_SuperMoose(object): (t_esc_SuperMoose(), "møose"), (t_esc_Unicode(), "é"), (t_esc_UnsafeAttrs(), "<UnsafeAttrs>"), - pytest.param(Exception("expected a '<'."), "expected a '<'.", marks=py2only), - pytest.param( - Exception("expected a '<'."), "expected a '<'.", marks=py3only - ), + pytest.param(Exception("expected a '<'."), "expected a '<'."), ], ) def test_html_escape(input, expected): diff --git a/tests/test_multidict.py b/tests/test_multidict.py index 5c9fa85..f040d4a 100644 --- a/tests/test_multidict.py +++ b/tests/test_multidict.py @@ -41,11 +41,8 @@ class BaseDictTests(object): def test_dict_api(self): self.assertTrue("a" in self.d.mixed()) self.assertTrue("a" in self.d.keys()) - self.assertTrue("a" in self.d.iterkeys()) self.assertTrue(("b", "1") in self.d.items()) - self.assertTrue(("b", "1") in self.d.iteritems()) self.assertTrue("1" in self.d.values()) - self.assertTrue("1" in self.d.itervalues()) self.assertEqual(len(self.d), 4) def test_set_del_item(self): @@ -502,10 +499,6 @@ class NoVarsTestCase(unittest.TestCase): d = self._get_instance() self.assertEqual(list(d.keys()), []) - def test_iterkeys(self): - d = self._get_instance() - self.assertEqual(list(d.iterkeys()), []) - class DummyField(object): def __init__(self, name, value, filename=None): -- cgit v1.2.1