summaryrefslogtreecommitdiff
path: root/cherrypy/test
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2016-09-08 13:48:20 +0300
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2016-09-08 13:48:20 +0300
commitc06aa3ff9cd0dd7a2c7eb994c7ae27b54851babb (patch)
tree7397ed2927341b4ab23f3b9304eca264c2f9618d /cherrypy/test
parent838736bd0c066bd53b0a5c5046d1a7ee9e54763b (diff)
downloadcherrypy-git-c06aa3ff9cd0dd7a2c7eb994c7ae27b54851babb.tar.gz
Fix E402 for test/_?test_*.py
Diffstat (limited to 'cherrypy/test')
-rw-r--r--cherrypy/test/_test_states_demo.py3
-rw-r--r--cherrypy/test/test_caching.py9
-rw-r--r--cherrypy/test/test_config.py5
-rw-r--r--cherrypy/test/test_config_server.py7
-rw-r--r--cherrypy/test/test_conn.py14
-rw-r--r--cherrypy/test/test_core.py6
-rw-r--r--cherrypy/test/test_encoding.py6
-rw-r--r--cherrypy/test/test_http.py5
-rw-r--r--cherrypy/test/test_iterator.py2
-rw-r--r--cherrypy/test/test_logging.py6
-rw-r--r--cherrypy/test/test_mime.py3
-rw-r--r--cherrypy/test/test_misc_tools.py10
-rw-r--r--cherrypy/test/test_refleaks.py7
-rw-r--r--cherrypy/test/test_request_obj.py9
-rw-r--r--cherrypy/test/test_routes.py7
-rwxr-xr-xcherrypy/test/test_session.py9
-rw-r--r--cherrypy/test/test_static.py13
-rw-r--r--cherrypy/test/test_tools.py18
-rw-r--r--cherrypy/test/test_virtualhost.py3
-rw-r--r--cherrypy/test/test_xmlrpc.py10
20 files changed, 69 insertions, 83 deletions
diff --git a/cherrypy/test/_test_states_demo.py b/cherrypy/test/_test_states_demo.py
index 75f9405c..a4b64e71 100644
--- a/cherrypy/test/_test_states_demo.py
+++ b/cherrypy/test/_test_states_demo.py
@@ -1,10 +1,11 @@
import os
import sys
import time
-starttime = time.time()
import cherrypy
+starttime = time.time()
+
class Root:
diff --git a/cherrypy/test/test_caching.py b/cherrypy/test/test_caching.py
index bac74351..ac559793 100644
--- a/cherrypy/test/test_caching.py
+++ b/cherrypy/test/test_caching.py
@@ -1,7 +1,6 @@
import datetime
from itertools import count
import os
-curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
import threading
import time
@@ -9,6 +8,11 @@ import cherrypy
from cherrypy._cpcompat import next, ntob, quote, xrange
from cherrypy.lib import httputil
+from cherrypy.test import helper
+
+
+curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
+
gif_bytes = ntob(
'GIF89a\x01\x00\x01\x00\x82\x00\x01\x99"\x1e\x00\x00\x00\x00\x00'
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
@@ -16,9 +20,6 @@ gif_bytes = ntob(
)
-from cherrypy.test import helper
-
-
class CacheTest(helper.CPWebCase):
@staticmethod
diff --git a/cherrypy/test/test_config.py b/cherrypy/test/test_config.py
index 088f95d4..195872f0 100644
--- a/cherrypy/test/test_config.py
+++ b/cherrypy/test/test_config.py
@@ -10,6 +10,9 @@ import six
import cherrypy
import cherrypy._cpcompat as compat
+from cherrypy.test import helper
+
+
localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
@@ -138,8 +141,6 @@ tools.staticfile.filename = %r
# Client-side code #
-from cherrypy.test import helper
-
class ConfigTests(helper.CPWebCase):
setup_server = staticmethod(setup_server)
diff --git a/cherrypy/test/test_config_server.py b/cherrypy/test/test_config_server.py
index 0ef11dec..7afc21b0 100644
--- a/cherrypy/test/test_config_server.py
+++ b/cherrypy/test/test_config_server.py
@@ -1,14 +1,15 @@
"""Tests for the CherryPy configuration system."""
import os
-localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
import cherrypy
+from cherrypy.test import helper
-# Client-side code #
+localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
-from cherrypy.test import helper
+
+# Client-side code #
class ServerConfigTests(helper.CPWebCase):
diff --git a/cherrypy/test/test_conn.py b/cherrypy/test/test_conn.py
index d3dc3f21..1382c9e0 100644
--- a/cherrypy/test/test_conn.py
+++ b/cherrypy/test/test_conn.py
@@ -1,21 +1,20 @@
"""Tests for TCP connection handling, including proper and timely close."""
+import errno
import socket
import sys
import time
-import errno
import six
import cherrypy
-from cherrypy._cpcompat import HTTPConnection, HTTPSConnection, NotConnected
from cherrypy._cpcompat import (
- BadStatusLine,
- ntob,
- tonative,
+ HTTPConnection, HTTPSConnection,
+ NotConnected, BadStatusLine,
+ ntob, tonative,
urlopen,
)
-from cherrypy.test import webtest
+from cherrypy.test import helper, webtest
timeout = 1
@@ -103,9 +102,6 @@ def setup_server():
})
-from cherrypy.test import helper
-
-
class ConnectionCloseTests(helper.CPWebCase):
setup_server = staticmethod(setup_server)
diff --git a/cherrypy/test/test_core.py b/cherrypy/test/test_core.py
index 53263957..fae1c27c 100644
--- a/cherrypy/test/test_core.py
+++ b/cherrypy/test/test_core.py
@@ -3,7 +3,6 @@
"""Basic tests for the CherryPy core: request handling."""
import os
-localDir = os.path.dirname(__file__)
import sys
import types
@@ -11,15 +10,16 @@ import cherrypy
from cherrypy._cpcompat import itervalues, ntob, ntou
from cherrypy import _cptools, tools
from cherrypy.lib import httputil, static
+
from cherrypy.test._test_decorators import ExposeExamples
+from cherrypy.test import helper
+localDir = os.path.dirname(__file__)
favicon_path = os.path.join(os.getcwd(), localDir, "../favicon.ico")
# Client-side code #
-from cherrypy.test import helper
-
class CoreRequestHandlingTest(helper.CPWebCase):
diff --git a/cherrypy/test/test_encoding.py b/cherrypy/test/test_encoding.py
index 633ac7e1..81a15727 100644
--- a/cherrypy/test/test_encoding.py
+++ b/cherrypy/test/test_encoding.py
@@ -10,6 +10,9 @@ import mock
import cherrypy
from cherrypy._cpcompat import IncompleteRead, ntob, ntou
+from cherrypy.test import helper
+
+
europoundUnicode = ntou('£', encoding='utf-8')
sing = ntou("毛泽东: Sing, Little Birdie?", encoding='utf-8')
@@ -17,9 +20,6 @@ sing8 = sing.encode('utf-8')
sing16 = sing.encode('utf-16')
-from cherrypy.test import helper
-
-
class EncodingTests(helper.CPWebCase):
@staticmethod
diff --git a/cherrypy/test/test_http.py b/cherrypy/test/test_http.py
index 48b60811..6a1c4bb8 100644
--- a/cherrypy/test/test_http.py
+++ b/cherrypy/test/test_http.py
@@ -12,6 +12,8 @@ from mock import patch
import cherrypy
from cherrypy._cpcompat import HTTPConnection, HTTPSConnection, ntob
+from cherrypy.test import helper
+
def encode_multipart_formdata(files):
"""Return (content_type, body) ready for httplib.HTTP instance.
@@ -35,9 +37,6 @@ def encode_multipart_formdata(files):
return content_type, body
-from cherrypy.test import helper
-
-
class HTTPTests(helper.CPWebCase):
def make_connection(self):
diff --git a/cherrypy/test/test_iterator.py b/cherrypy/test/test_iterator.py
index 28d5049e..90872f3a 100644
--- a/cherrypy/test/test_iterator.py
+++ b/cherrypy/test/test_iterator.py
@@ -1,6 +1,7 @@
import six
import cherrypy
+from cherrypy.test import helper
class IteratorBase(object):
@@ -71,7 +72,6 @@ class OurNotClosableIterator(OurIterator):
class OurUnclosableIterator(OurIterator):
close = 'close' # not callable!
-from cherrypy.test import helper
class IteratorTest(helper.CPWebCase):
@staticmethod
diff --git a/cherrypy/test/test_logging.py b/cherrypy/test/test_logging.py
index ebaced89..254ee2c7 100644
--- a/cherrypy/test/test_logging.py
+++ b/cherrypy/test/test_logging.py
@@ -1,13 +1,14 @@
"""Basic tests for the CherryPy core: request handling."""
import os
-localDir = os.path.dirname(__file__)
import six
import cherrypy
from cherrypy._cpcompat import ntob, ntou
+from cherrypy.test import helper, logtest
+localDir = os.path.dirname(__file__)
access_log = os.path.join(localDir, "access.log")
error_log = os.path.join(localDir, "error.log")
@@ -63,9 +64,6 @@ def setup_server():
cherrypy.tree.mount(root)
-from cherrypy.test import helper, logtest
-
-
class AccessLogTests(helper.CPWebCase, logtest.LogCase):
setup_server = staticmethod(setup_server)
diff --git a/cherrypy/test/test_mime.py b/cherrypy/test/test_mime.py
index 7826fd56..f52a241e 100644
--- a/cherrypy/test/test_mime.py
+++ b/cherrypy/test/test_mime.py
@@ -2,6 +2,7 @@
import cherrypy
from cherrypy._cpcompat import ntob, ntou, sorted
+from cherrypy.test import helper
def setup_server():
@@ -27,8 +28,6 @@ def setup_server():
# Client-side code #
-from cherrypy.test import helper
-
class MultipartTest(helper.CPWebCase):
setup_server = staticmethod(setup_server)
diff --git a/cherrypy/test/test_misc_tools.py b/cherrypy/test/test_misc_tools.py
index 4e38cd1c..b2565798 100644
--- a/cherrypy/test/test_misc_tools.py
+++ b/cherrypy/test/test_misc_tools.py
@@ -1,9 +1,12 @@
import os
-localDir = os.path.dirname(__file__)
-logfile = os.path.join(localDir, "test_misc_tools.log")
import cherrypy
from cherrypy import tools
+from cherrypy.test import helper
+
+
+localDir = os.path.dirname(__file__)
+logfile = os.path.join(localDir, "test_misc_tools.log")
def setup_server():
@@ -98,9 +101,6 @@ def setup_server():
cherrypy.config.update({'log.error_file': logfile})
-from cherrypy.test import helper
-
-
class ResponseHeadersTest(helper.CPWebCase):
setup_server = staticmethod(setup_server)
diff --git a/cherrypy/test/test_refleaks.py b/cherrypy/test/test_refleaks.py
index 929f6b1f..a6249e0d 100644
--- a/cherrypy/test/test_refleaks.py
+++ b/cherrypy/test/test_refleaks.py
@@ -2,19 +2,16 @@
import itertools
import platform
-
-from cherrypy._cpcompat import HTTPConnection, HTTPSConnection
import threading
import cherrypy
+from cherrypy._cpcompat import HTTPConnection, HTTPSConnection
+from cherrypy.test import helper
data = object()
-from cherrypy.test import helper
-
-
class ReferenceTests(helper.CPWebCase):
@staticmethod
diff --git a/cherrypy/test/test_request_obj.py b/cherrypy/test/test_request_obj.py
index 2ad06fa8..ed6bfe8c 100644
--- a/cherrypy/test/test_request_obj.py
+++ b/cherrypy/test/test_request_obj.py
@@ -1,16 +1,17 @@
"""Basic tests for the cherrypy.Request object."""
import os
-localDir = os.path.dirname(__file__)
import sys
import types
import six
-from cherrypy._cpcompat import IncompleteRead, ntob, ntou
-
import cherrypy
+from cherrypy._cpcompat import IncompleteRead, ntob, ntou
from cherrypy.lib import httputil
+from cherrypy.test import helper
+
+localDir = os.path.dirname(__file__)
defined_http_methods = ("OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE",
"TRACE", "PROPFIND")
@@ -18,8 +19,6 @@ defined_http_methods = ("OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE",
# Client-side code #
-from cherrypy.test import helper
-
class RequestObjectTests(helper.CPWebCase):
diff --git a/cherrypy/test/test_routes.py b/cherrypy/test/test_routes.py
index ccc76574..6c7ff67e 100644
--- a/cherrypy/test/test_routes.py
+++ b/cherrypy/test/test_routes.py
@@ -1,10 +1,11 @@
import os
-curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
-import cherrypy
+import nose
+import cherrypy
from cherrypy.test import helper
-import nose
+
+curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
class RoutesDispatchTest(helper.CPWebCase):
diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py
index 3e39e472..5dad9275 100755
--- a/cherrypy/test/test_session.py
+++ b/cherrypy/test/test_session.py
@@ -1,13 +1,16 @@
import os
-localDir = os.path.dirname(__file__)
import threading
import time
+import socket
import cherrypy
from cherrypy._cpcompat import copykeys, HTTPConnection, HTTPSConnection
from cherrypy.lib import sessions
from cherrypy.lib import reprconf
from cherrypy.lib.httputil import response_codes
+from cherrypy.test import helper
+
+localDir = os.path.dirname(__file__)
def http_methods_allowed(methods=['GET', 'HEAD']):
@@ -126,9 +129,6 @@ def setup_server():
cherrypy.tree.mount(Root())
-from cherrypy.test import helper
-
-
class SessionTest(helper.CPWebCase):
setup_server = staticmethod(setup_server)
@@ -376,7 +376,6 @@ class SessionTest(helper.CPWebCase):
t.join()
-import socket
try:
import memcache # NOQA
diff --git a/cherrypy/test/test_static.py b/cherrypy/test/test_static.py
index f98d17c2..8e365665 100644
--- a/cherrypy/test/test_static.py
+++ b/cherrypy/test/test_static.py
@@ -1,14 +1,18 @@
# -*- coding: utf-8 -*-
+import contextlib
+import io
import os
import sys
-import io
-import contextlib
from six.moves import urllib
+import cherrypy
+from cherrypy.lib import static
from cherrypy._cpcompat import (
HTTPConnection, HTTPSConnection, ntou, tonative,
)
+from cherrypy.test import helper
+
curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
has_space_filepath = os.path.join(curdir, 'static', 'has space.html')
@@ -20,10 +24,6 @@ bigfile_filepath = os.path.join(curdir, "static", "bigfile.log")
MB = 2 ** 20
BIGFILE_SIZE = 32 * MB
-import cherrypy
-from cherrypy.lib import static
-from cherrypy.test import helper
-
class StaticTest(helper.CPWebCase):
@@ -45,7 +45,6 @@ class StaticTest(helper.CPWebCase):
@cherrypy.expose
@cherrypy.config(**{'response.stream': True})
def bigfile(self):
- from cherrypy.lib import static
self.f = static.serve_file(bigfile_filepath)
return self.f
diff --git a/cherrypy/test/test_tools.py b/cherrypy/test/test_tools.py
index 489a48b3..e2f8f9bb 100644
--- a/cherrypy/test/test_tools.py
+++ b/cherrypy/test/test_tools.py
@@ -1,29 +1,27 @@
"""Test the various means of instantiating and invoking tools."""
import gzip
-import sys
-import unittest
import io
-
-from cherrypy._cpcompat import copyitems, itervalues
-from cherrypy._cpcompat import IncompleteRead, ntob, ntou, xrange
+import sys
import time
-timeout = 0.2
import types
+import unittest
import six
import cherrypy
from cherrypy import tools
+from cherrypy._cpcompat import copyitems, itervalues
+from cherrypy._cpcompat import IncompleteRead, ntob, ntou, xrange
+from cherrypy.test import helper, _test_decorators
+timeout = 0.2
europoundUnicode = ntou('\x80\xa3')
# Client-side code #
-from cherrypy.test import helper
-
class ToolTests(helper.CPWebCase):
@@ -252,9 +250,7 @@ class ToolTests(helper.CPWebCase):
app = cherrypy.tree.mount(root, config=conf)
app.request_class.namespaces['myauth'] = myauthtools
- if sys.version_info >= (2, 5):
- from cherrypy.test import _test_decorators
- root.tooldecs = _test_decorators.ToolExamples()
+ root.tooldecs = _test_decorators.ToolExamples()
def testHookErrors(self):
self.getPage("/demo/?id=1")
diff --git a/cherrypy/test/test_virtualhost.py b/cherrypy/test/test_virtualhost.py
index a495cbb3..d0af0fd6 100644
--- a/cherrypy/test/test_virtualhost.py
+++ b/cherrypy/test/test_virtualhost.py
@@ -1,9 +1,10 @@
import os
-curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
import cherrypy
from cherrypy.test import helper
+curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
+
class VirtualHostTest(helper.CPWebCase):
diff --git a/cherrypy/test/test_xmlrpc.py b/cherrypy/test/test_xmlrpc.py
index e95d5d79..254730b7 100644
--- a/cherrypy/test/test_xmlrpc.py
+++ b/cherrypy/test/test_xmlrpc.py
@@ -9,6 +9,10 @@ except ImportError:
from xmlrpc.client import DateTime, Fault, ProtocolError, ServerProxy
from xmlrpc.client import SafeTransport
+import cherrypy
+from cherrypy import _cptools
+from cherrypy.test import helper
+
if six.PY3:
HTTPSTransport = SafeTransport
@@ -48,11 +52,8 @@ else:
return self.parse_response(h.getfile())
-import cherrypy
-
def setup_server():
- from cherrypy import _cptools
class Root:
@@ -118,9 +119,6 @@ def setup_server():
}})
-from cherrypy.test import helper
-
-
class XmlRpcTest(helper.CPWebCase):
setup_server = staticmethod(setup_server)