diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-21 15:26:47 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-21 15:26:47 +0200 |
commit | 204ef6b7198467a5bd94ae3235b3a318ff0ccc2b (patch) | |
tree | b0a470e46326b709d090a900847bbb004d355607 | |
parent | 3c66ac4214f3a86f7530e75564dbb876e034581f (diff) | |
download | paste-git-204ef6b7198467a5bd94ae3235b3a318ff0ccc2b.tar.gz |
Strip trailing spaces
52 files changed, 225 insertions, 225 deletions
diff --git a/paste/__init__.py b/paste/__init__.py index ba66606..4e2d638 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -6,7 +6,7 @@ try: except ImportError: # don't prevent use of paste if pkg_resources isn't installed from pkgutil import extend_path - __path__ = extend_path(__path__, __name__) + __path__ = extend_path(__path__, __name__) try: import modulefinder diff --git a/paste/auth/basic.py b/paste/auth/basic.py index 69db128..24d1731 100644 --- a/paste/auth/basic.py +++ b/paste/auth/basic.py @@ -108,14 +108,14 @@ def make_basic(app, global_conf, realm, authfunc, **kw): use = egg:Paste#auth_basic realm=myrealm authfunc=somepackage.somemodule:somefunction - + """ from paste.util.import_string import eval_import import types authfunc = eval_import(authfunc) assert isinstance(authfunc, types.FunctionType), "authfunc must resolve to a function" return AuthBasicHandler(app, realm, authfunc) - + if "__main__" == __name__: import doctest diff --git a/paste/auth/cookie.py b/paste/auth/cookie.py index c636824..14b1fd8 100644 --- a/paste/auth/cookie.py +++ b/paste/auth/cookie.py @@ -368,7 +368,7 @@ def make_auth_cookie( The maximum length of the cookie that is sent (default 4k, which is a typical browser maximum) - + """ if isinstance(scanlist, six.string_types): scanlist = scanlist.split() diff --git a/paste/auth/form.py b/paste/auth/form.py index 4e6aa49..9be82a2 100644 --- a/paste/auth/form.py +++ b/paste/auth/form.py @@ -131,7 +131,7 @@ def make_form(app, global_conf, realm, authfunc, **kw): use = egg:Paste#auth_form realm=myrealm authfunc=somepackage.somemodule:somefunction - + """ from paste.util.import_string import eval_import import types diff --git a/paste/auth/grantip.py b/paste/auth/grantip.py index 4ea6df5..2ee9bcf 100644 --- a/paste/auth/grantip.py +++ b/paste/auth/grantip.py @@ -38,7 +38,7 @@ class GrantIPMiddleware(object): if roles and isinstance(roles, six.string_types): roles = roles.split(',') return (username, roles) - + def __call__(self, environ, start_response): addr = ip4.ip2int(environ['REMOTE_ADDR'], False) remove_user = False @@ -74,8 +74,8 @@ class GrantIPMiddleware(object): if role in cur_roles: cur_roles.remove(role) environ['REMOTE_USER_TOKENS'] = ','.join(cur_roles) - - + + def make_grantip(app, global_conf, clobber_username=False, **kw): """ Grant roles or usernames based on IP addresses. @@ -93,7 +93,7 @@ def make_grantip(app, global_conf, clobber_username=False, **kw): 192.168.0.7 = joe # And one IP is should not be logged in: 192.168.0.10 = __remove__:-editor - + """ from paste.deploy.converters import asbool clobber_username = asbool(clobber_username) @@ -110,5 +110,5 @@ def make_grantip(app, global_conf, clobber_username=False, **kw): role = '' ip_map[key] = value return GrantIPMiddleware(app, ip_map, clobber_username) - - + + diff --git a/paste/auth/open_id.py b/paste/auth/open_id.py index 967e699..f79f7f8 100644 --- a/paste/auth/open_id.py +++ b/paste/auth/open_id.py @@ -91,20 +91,20 @@ class AuthOpenIDHandler(object): ``app`` Your WSGI app to call - + ``data_store_path`` Directory to store crypto data in for use with OpenID servers. - + ``auth_prefix`` Location for authentication process/verification - + ``login_redirect`` Location to load after successful process of login - + ``catch_401`` If true, then any 401 responses will turn into open ID login requirements. - + ``url_to_username`` A function called like ``url_to_username(environ, url)``, which should return a string username. If not given, the URL will be the username. diff --git a/paste/cascade.py b/paste/cascade.py index 424794e..8207ae3 100644 --- a/paste/cascade.py +++ b/paste/cascade.py @@ -15,7 +15,7 @@ __all__ = ['Cascade'] def make_cascade(loader, global_conf, catch='404', **local_conf): """ Entry point for Paste Deploy configuration - + Expects configuration like:: [composit:cascade] @@ -39,7 +39,7 @@ def make_cascade(loader, global_conf, catch='404', **local_conf): apps.sort() apps = [app for name, app in apps] return Cascade(apps, catch=catch) - + class Cascade(object): """ @@ -70,7 +70,7 @@ class Cascade(object): self.catch_codes[code] = exc self.catch_exceptions.append(exc) self.catch_exceptions = tuple(self.catch_exceptions) - + def __call__(self, environ, start_response): """ WSGI application interface diff --git a/paste/cgitb_catcher.py b/paste/cgitb_catcher.py index 55a346f..3185506 100644 --- a/paste/cgitb_catcher.py +++ b/paste/cgitb_catcher.py @@ -83,7 +83,7 @@ class CgitbMiddleware(object): format=self.format) hook(*exc_info) return dummy_file.getvalue() - + def make_cgitb_middleware(app, global_conf, display=NoDefault, logdir=None, @@ -92,7 +92,7 @@ def make_cgitb_middleware(app, global_conf, """ Wraps the application in the ``cgitb`` (standard library) error catcher. - + display: If true (or debug is set in the global configuration) then the traceback will be displayed in the browser diff --git a/paste/cowbell/__init__.py b/paste/cowbell/__init__.py index 43b7097..5a0d22d 100644 --- a/paste/cowbell/__init__.py +++ b/paste/cowbell/__init__.py @@ -45,7 +45,7 @@ function showSomewhere() { var sec, el; if (cowbellState == 'hidden') { el = document.getElementById('cowbell-ascending'); - lastCowbellPosition = [parseInt(Math.random()*(window.innerWidth-200)), + lastCowbellPosition = [parseInt(Math.random()*(window.innerWidth-200)), parseInt(Math.random()*(window.innerHeight-200))]; el.style.left = lastCowbellPosition[0] + 'px'; el.style.top = lastCowbellPosition[1] + 'px'; diff --git a/paste/debug/doctest_webapp.py b/paste/debug/doctest_webapp.py index f399ac3..4b9f95a 100755 --- a/paste/debug/doctest_webapp.py +++ b/paste/debug/doctest_webapp.py @@ -214,7 +214,7 @@ def show_file(path, version, description=None, data=None): data = f.read() f.close() if ext == '.py': - html = ('<div class="source-code">%s</div>' + html = ('<div class="source-code">%s</div>' % PySourceColor.str2html(data, PySourceColor.dark)) else: html = '<pre class="source-code">%s</pre>' % cgi.escape(data, 1) @@ -241,7 +241,7 @@ def write_data(path, data): f = open(path, 'wb') f.write(data) f.close() - + def change_file(path, changes): f = open(os.path.abspath(path), 'rb') @@ -282,7 +282,7 @@ class LongFormDocTestParser(doctest.DocTestParser): (?![ ]*>>>) # Not a line starting with PS1 .*$\n? # But any other line )*)) - | + | (?: # This is for longer commands that are prefixed with a reST # comment like '.. run:' (two colons makes that a directive). # These commands cannot have any output. @@ -331,7 +331,7 @@ class LongFormDocTestParser(doctest.DocTestParser): # Get the example's indentation level. runner = m.group('run') or '' indent = len(m.group('%sindent' % runner)) - + # Divide source into lines; check that they're properly # indented; and then strip their indentation & prompts. source_lines = m.group('%ssource' % runner).split('\n') diff --git a/paste/debug/fsdiff.py b/paste/debug/fsdiff.py index 156a2e4..b91eb49 100644 --- a/paste/debug/fsdiff.py +++ b/paste/debug/fsdiff.py @@ -298,7 +298,7 @@ class Dir(File): "Directory %r doesn't have content" % self) bytes = property(bytes__get) - + def _space_prefix(pref, full, sep=None, indent=None, include_sep=True): """ diff --git a/paste/debug/prints.py b/paste/debug/prints.py index 6cc3f7d..b660bfa 100644 --- a/paste/debug/prints.py +++ b/paste/debug/prints.py @@ -132,7 +132,7 @@ class PrintDebugMiddleware(object): _body_re = re.compile(r'<body[^>]*>', re.I) _explicit_re = re.compile(r'<pre\s*[^>]*id="paste-debug-prints".*?>', re.I+re.S) - + def add_log(self, html, log): if not log: return html diff --git a/paste/debug/profile.py b/paste/debug/profile.py index 036c805..470a54a 100644 --- a/paste/debug/profile.py +++ b/paste/debug/profile.py @@ -100,7 +100,7 @@ def profile_decorator(**options): """ Profile a single function call. - + Used around a function, like:: @profile_decorator(options...) @@ -203,14 +203,14 @@ class DecoratedProfile(object): # We captured an exception earlier, now we re-raise it six.reraise(exc_info[0], exc_info[1], exc_info[2]) return result - + def format_function(self, func, *args, **kw): args = map(repr, args) args.extend( ['%s=%r' % (k, v) for k, v in kw.items()]) return '%s(%s)' % (func.__name__, ', '.join(args)) - - + + def make_profile_middleware( app, global_conf, log_filename='profile.log.tmp', diff --git a/paste/debug/testserver.py b/paste/debug/testserver.py index 4817161..8044c7c 100755 --- a/paste/debug/testserver.py +++ b/paste/debug/testserver.py @@ -28,7 +28,7 @@ class WSGIRegressionServer(WSGIServer): self.pending = [] self.timeout = self.defaulttimeout # this is a local connection, be quick - self.socket.settimeout(2) + self.socket.settimeout(2) def serve_forever(self): from threading import Thread thread = Thread(target=self.serve_pending) @@ -75,13 +75,13 @@ if __name__ == '__main__': def fetch(path): # tell the server to humor exactly one more request server.accept(1) - # not needed; but this is what you do if the server + # not needed; but this is what you do if the server # may not respond in a resonable time period import socket socket.setdefaulttimeout(5) # build a uri, fetch and return return urlopen(baseuri + path).read() - + assert "PATH_INFO: /foo" in fetch("/foo") assert "PATH_INFO: /womble" in fetch("/womble") diff --git a/paste/debug/watchthreads.py b/paste/debug/watchthreads.py index c877942..b06ccea 100644 --- a/paste/debug/watchthreads.py +++ b/paste/debug/watchthreads.py @@ -123,7 +123,7 @@ page_template = HTMLTemplate(''' } return false ">▸ Show environ</a> - + <div id="environ-{{thread.thread_id}}" style="display: none"> {{if thread.environ:}} <table class="environ"> @@ -221,7 +221,7 @@ class WatchThreads(object): thread.uri_short = shorten(thread.uri) thread.environ = worker_environ thread.traceback = traceback_thread(thread_id) - + page = page_template.substitute( title="Thread Pool Worker Tracker", nworkers=nworkers, @@ -255,7 +255,7 @@ class WatchThreads(object): exc = httpexceptions.HTTPFound( headers=[('Location', script_name+'?kill=%s' % thread_id)]) return exc(environ, start_response) - + def traceback_thread(thread_id): """ Returns a plain-text traceback of the given thread, or None if it @@ -296,7 +296,7 @@ def format_environ(environ): key=cgi.escape(str(key)), value='Error in <code>repr()</code>: %s' % e)) return ''.join(environ_rows) - + def format_time(time_length): if time_length >= 60*60: # More than an hour diff --git a/paste/exceptions/collector.py b/paste/exceptions/collector.py index d6a30db..8867bf7 100644 --- a/paste/exceptions/collector.py +++ b/paste/exceptions/collector.py @@ -92,7 +92,7 @@ class ExceptionCollector(object): The actually interpretation of these values is largely up to the reporters and formatters. - + ``collect_exception(*sys.exc_info())`` will return an object with several attributes: @@ -113,7 +113,7 @@ class ExceptionCollector(object): can refer to the exception later. (@@: should it include a portion that allows identification of the specific instance of the exception as well?) - + The list of frames goes innermost first. Each frame has these attributes; some values may be None if they could not be determined. @@ -140,7 +140,7 @@ class ExceptionCollector(object): the value of any ``__traceback_hide__`` variable ``traceback_log``: the value of any ``__traceback_log__`` variable - + ``__traceback_supplement__`` is thrown away, but a fixed set of attributes are captured; each of these attributes is @@ -189,7 +189,7 @@ class ExceptionCollector(object): hide frames that are part of the 'framework' or underlying system. There are a variety of rules about special values for this variables that formatters should be aware of. - + TODO: More attributes in __traceback_supplement__? Maybe an attribute @@ -503,7 +503,7 @@ class ExceptionFrame(Bunch): for lineno in range(self.lineno-context, self.lineno+context+1): lines.append(linecache.getline(self.filename, lineno)) return ''.join(lines) - + if hasattr(sys, 'tracebacklimit'): limit = min(limit, sys.tracebacklimit) @@ -512,7 +512,7 @@ col = ExceptionCollector() def collect_exception(t, v, tb, limit=None): """ Collection an exception from ``sys.exc_info()``. - + Use like:: try: diff --git a/paste/exceptions/errormiddleware.py b/paste/exceptions/errormiddleware.py index 7a0918a..3202ee2 100644 --- a/paste/exceptions/errormiddleware.py +++ b/paste/exceptions/errormiddleware.py @@ -23,7 +23,7 @@ class ErrorMiddleware(object): """ Error handling middleware - + Usage:: error_catching_wsgi_app = ErrorMiddleware(wsgi_app) @@ -34,14 +34,14 @@ class ErrorMiddleware(object): If true, then tracebacks will be shown in the browser. ``error_email``: - an email address (or list of addresses) to send exception + an email address (or list of addresses) to send exception reports to ``error_log``: a filename to append tracebacks to ``show_exceptions_in_wsgi_errors``: - If true, then errors will be printed to ``wsgi.errors`` + If true, then errors will be printed to ``wsgi.errors`` (frequently a server error log, or stderr). ``from_address``, ``smtp_server``, ``error_subject_prefix``, ``smtp_username``, ``smtp_password``, ``smtp_use_tls``: @@ -57,7 +57,7 @@ class ErrorMiddleware(object): HTML page. Environment Configuration: - + ``paste.throw_errors``: If this setting in the request environment is true, then this middleware is disabled. This can be useful in a testing situation @@ -65,10 +65,10 @@ class ErrorMiddleware(object): ``paste.expected_exceptions``: When this middleware encounters an exception listed in this - environment variable and when the ``start_response`` has not + environment variable and when the ``start_response`` has not yet occurred, the exception will be re-raised instead of being - caught. This should generally be set by middleware that may - (but probably shouldn't be) installed above this middleware, + caught. This should generally be set by middleware that may + (but probably shouldn't be) installed above this middleware, and wants to get certain exceptions. Exceptions raised after ``start_response`` have been called are always caught since by definition they are no longer expected. @@ -123,7 +123,7 @@ class ErrorMiddleware(object): if xmlhttp_key is None: xmlhttp_key = global_conf.get('xmlhttp_key', '_') self.xmlhttp_key = xmlhttp_key - + def __call__(self, environ, start_response): """ The WSGI application interface. @@ -313,7 +313,7 @@ class Supplement(object): (1, 0, 1): 'CGI', (1, 1, 1): 'Multi thread/process CGI (?)', } - + def handle_exception(exc_info, error_stream, html=True, debug_mode=False, error_email=None, @@ -321,8 +321,8 @@ def handle_exception(exc_info, error_stream, html=True, show_exceptions_in_wsgi_errors=False, error_email_from='errors@localhost', smtp_server='localhost', - smtp_username=None, - smtp_password=None, + smtp_username=None, + smtp_password=None, smtp_use_tls=False, error_subject_prefix='', error_message=None, diff --git a/paste/exceptions/formatter.py b/paste/exceptions/formatter.py index 7fa5e7d..c83ab50 100644 --- a/paste/exceptions/formatter.py +++ b/paste/exceptions/formatter.py @@ -196,7 +196,7 @@ class TextFormatter(AbstractFormatter): '%s: %s' % (self.quote(etype), self.quote(evalue))) def format_traceback_info(self, info): return info - + def format_combine(self, data_by_importance, lines, exc_info): lines[:0] = [value for n, value in data_by_importance['important']] lines.append(exc_info) @@ -380,7 +380,7 @@ function switch_source(el, hide_type) { } </script>''' - + error_css = """ <style type="text/css"> @@ -464,7 +464,7 @@ def format_html(exc_data, include_hidden_frames=False, **ops): <textarea style="width: 100%%" rows=10 cols=60>%s</textarea> </div> """ % (short_er, long_er, cgi.escape(text_er)) - + def format_text(exc_data, **ops): return TextFormatter(**ops).format_collected_data(exc_data) diff --git a/paste/exceptions/serial_number_generator.py b/paste/exceptions/serial_number_generator.py index d4f6235..5315b7c 100644 --- a/paste/exceptions/serial_number_generator.py +++ b/paste/exceptions/serial_number_generator.py @@ -122,4 +122,4 @@ __test__ = { if __name__ == '__main__': import doctest doctest.testmod() - + diff --git a/paste/flup_session.py b/paste/flup_session.py index 6903c6f..6f5c750 100644 --- a/paste/flup_session.py +++ b/paste/flup_session.py @@ -68,7 +68,7 @@ class SessionMiddleware(object): if cookie_name is NoDefault: cookie_name = global_conf.get('session_cookie', '_SID_') self.cookie_name = cookie_name - + def __call__(self, environ, start_response): service = flup_session.SessionService( self.store, environ, cookieName=self.cookie_name, @@ -92,7 +92,7 @@ class SessionMiddleware(object): raise return wsgilib.add_close(app_iter, service.close) - + def make_session_middleware(app, global_conf, session_type=NoDefault, cookie_name=NoDefault, diff --git a/paste/lint.py b/paste/lint.py index 0eedfa2..fac8948 100644 --- a/paste/lint.py +++ b/paste/lint.py @@ -133,7 +133,7 @@ def middleware(application, global_conf=None): will be printed to stderr -- there's no way to throw an exception at that point). """ - + def lint_app(*args, **kw): assert len(args) == 2, "Two arguments required" assert not kw, "No keyword arguments allowed" @@ -200,7 +200,7 @@ class InputWrapper(object): for line in lines: assert type(line) is type("") return lines - + def __iter__(self): while 1: line = self.readline() @@ -270,7 +270,7 @@ class IteratorWrapper(object): return v __next__ = next - + def close(self): self.closed = True if hasattr(self.original_iterator, 'close'): @@ -287,7 +287,7 @@ def check_environ(environ): assert isinstance(environ,dict), ( "Environment is not of the right type: %r (environment: %r)" % (type(environ), environ)) - + for key in ['REQUEST_METHOD', 'SERVER_NAME', 'SERVER_PORT', 'wsgi.version', 'wsgi.input', 'wsgi.errors', 'wsgi.multithread', 'wsgi.multiprocess', @@ -314,7 +314,7 @@ def check_environ(environ): assert isinstance(environ[key], str), ( "Environmental variable %s is not a string: %r (value: %r)" % (key, type(environ[key]), environ[key])) - + assert isinstance(environ['wsgi.version'], tuple), ( "wsgi.version should be a tuple (%r)" % environ['wsgi.version']) assert environ['wsgi.url_scheme'] in ('http', 'https'), ( diff --git a/paste/modpython.py b/paste/modpython.py index 692a94f..d20a588 100644 --- a/paste/modpython.py +++ b/paste/modpython.py @@ -8,7 +8,7 @@ Example httpd.conf section for a Paste app with an ini file:: PythonHandler paste.modpython PythonOption paste.ini /some/location/your/pasteconfig.ini </Location> - + Or if you want to load a WSGI application under /your/homedir in the module ``startup`` and the WSGI app is ``app``:: @@ -59,22 +59,22 @@ except: from paste.deploy import loadapp class InputWrapper(object): - + def __init__(self, req): self.req = req - + def close(self): pass - + def read(self, size=-1): return self.req.read(size) - + def readline(self, size=-1): return self.req.readline(size) - + def readlines(self, hint=-1): return self.req.readlines(hint) - + def __iter__(self): line = self.readline() while line: @@ -85,16 +85,16 @@ class InputWrapper(object): class ErrorWrapper(object): - + def __init__(self, req): self.req = req - + def flush(self): pass - + def write(self, msg): self.req.log_error(msg) - + def writelines(self, seq): self.write(''.join(seq)) @@ -104,12 +104,12 @@ bad_value = ("You must provide a PythonOption '%s', either 'on' or 'off', " class Handler(object): - + def __init__(self, req): self.started = False - + options = req.get_options() - + # Threading and forking try: q = apache.mpm_query @@ -123,7 +123,7 @@ class Handler(object): threaded = False else: raise ValueError(bad_value % "multithread") - + forked = options.get('multiprocess', '').lower() if forked == 'on': forked = True @@ -131,9 +131,9 @@ class Handler(object): forked = False else: raise ValueError(bad_value % "multiprocess") - + env = self.environ = dict(apache.build_cgi_env(req)) - + if 'SCRIPT_NAME' in options: # Override SCRIPT_NAME and PATH_INFO if requested. env['SCRIPT_NAME'] = options['SCRIPT_NAME'] @@ -141,7 +141,7 @@ class Handler(object): else: env['SCRIPT_NAME'] = '' env['PATH_INFO'] = req.uri - + env['wsgi.input'] = InputWrapper(req) env['wsgi.errors'] = ErrorWrapper(req) env['wsgi.version'] = (1, 0) @@ -152,9 +152,9 @@ class Handler(object): env['wsgi.url_scheme'] = 'http' env['wsgi.multithread'] = threaded env['wsgi.multiprocess'] = forked - + self.request = req - + def run(self, application): try: result = application(self.environ, self.start_response) @@ -172,7 +172,7 @@ class Handler(object): data = "A server error occurred. Please contact the administrator." self.request.set_content_length(len(data)) self.request.write(data) - + def start_response(self, status, headers, exc_info=None): if exc_info: try: @@ -180,9 +180,9 @@ class Handler(object): six.reraise(exc_info[0], exc_info[1], exc_info[2]) finally: exc_info = None - + self.request.status = int(status[:3]) - + for key, val in headers: if key.lower() == 'content-length': self.request.set_content_length(int(val)) @@ -190,9 +190,9 @@ class Handler(object): self.request.content_type = val else: self.request.headers_out.add(key, val) - + return self.write - + def write(self, data): if not self.started: self.started = True @@ -214,7 +214,7 @@ def handler(req): module = __import__(module_name, globals(), locals(), ['']) startup = apache.resolve_object(module, object_str) startup(req) - + # Register a cleanup function if requested. global cleanup if 'wsgi.cleanup' in options and not cleanup: @@ -230,7 +230,7 @@ def handler(req): apache.register_cleanup(cleaner) except AttributeError: req.server.register_cleanup(req, cleaner) - + # Import the wsgi 'application' callable and pass it to Handler.run global wsgiapps appini = options.get('paste.ini') @@ -239,15 +239,15 @@ def handler(req): if appini not in wsgiapps: wsgiapps[appini] = loadapp("config:%s" % appini) app = wsgiapps[appini] - + # Import the wsgi 'application' callable and pass it to Handler.run appwsgi = options.get('wsgi.application') if appwsgi and not appini: modname, objname = appwsgi.split('::', 1) module = __import__(modname, globals(), locals(), ['']) app = getattr(module, objname) - + Handler(req).run(app) - + # status was set in Handler; always return apache.OK return apache.OK diff --git a/paste/proxy.py b/paste/proxy.py index a33efbc..b315265 100644 --- a/paste/proxy.py +++ b/paste/proxy.py @@ -21,12 +21,12 @@ TODO: * Rewriting body? (Probably not on this one -- that can be done with a different middleware that wraps this middleware) -* Example:: - +* Example:: + use = egg:Paste#proxy address = http://server3:8680/exist/rest/db/orgs/sch/config/ allowed_request_methods = GET - + """ from six.moves import http_client as httplib @@ -38,7 +38,7 @@ from paste.util.converters import aslist # Remove these headers from response (specify lower case header # names): -filtered_headers = ( +filtered_headers = ( 'transfer-encoding', 'connection', 'keep-alive', @@ -60,12 +60,12 @@ class Proxy(object): self.path = self.parsed[2] self.allowed_request_methods = [ x.lower() for x in allowed_request_methods if x] - + self.suppress_http_headers = [ x.lower() for x in suppress_http_headers if x] def __call__(self, environ, start_response): - if (self.allowed_request_methods and + if (self.allowed_request_methods and environ['REQUEST_METHOD'].lower() not in self.allowed_request_methods): return httpexceptions.HTTPBadRequest("Disallowed")(environ, start_response) @@ -95,30 +95,30 @@ class Proxy(object): body = environ['wsgi.input'].read(-1) headers['content-length'] = str(len(body)) else: - headers['content-length'] = environ['CONTENT_LENGTH'] + headers['content-length'] = environ['CONTENT_LENGTH'] length = int(environ['CONTENT_LENGTH']) body = environ['wsgi.input'].read(length) else: body = '' - + path_info = quote(environ['PATH_INFO']) - if self.path: + if self.path: request_path = path_info if request_path and request_path[0] == '/': request_path = request_path[1:] - + path = urlparse.urljoin(self.path, request_path) else: path = path_info if environ.get('QUERY_STRING'): path += '?' + environ['QUERY_STRING'] - + conn.request(environ['REQUEST_METHOD'], path, body, headers) res = conn.getresponse() headers_out = parse_headers(res.msg) - + status = '%s %s' % (res.status, res.reason) start_response(status, headers_out) # @@: Default? @@ -134,13 +134,13 @@ def make_proxy(global_conf, address, allowed_request_methods="", suppress_http_headers=""): """ Make a WSGI application that proxies to another address: - + ``address`` the full URL ending with a trailing ``/`` - + ``allowed_request_methods``: a space seperated list of request methods (e.g., ``GET POST``) - + ``suppress_http_headers`` a space seperated list of http headers (lower case, without the leading ``http_``) that should not be passed on to target @@ -224,7 +224,7 @@ class TransparentProxy(object): else: body = '' length = 0 - + path = (environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')) path = quote(path) @@ -234,7 +234,7 @@ class TransparentProxy(object): path, body, headers) res = conn.getresponse() headers_out = parse_headers(res.msg) - + status = '%s %s' % (res.status, res.reason) start_response(status, headers_out) # @@: Default? @@ -250,27 +250,27 @@ def parse_headers(message): """ Turn a Message object into a list of WSGI-style headers. """ - headers_out = [] + headers_out = [] for full_header in message.headers: - if not full_header: + if not full_header: # Shouldn't happen, but we'll just ignore - continue + continue if full_header[0].isspace(): # Continuation line, add to the last header - if not headers_out: + if not headers_out: raise ValueError( "First header starts with a space (%r)" % full_header) - last_header, last_value = headers_out.pop() + last_header, last_value = headers_out.pop() value = last_value + ' ' + full_header.strip() - headers_out.append((last_header, value)) - continue - try: + headers_out.append((last_header, value)) + continue + try: header, value = full_header.split(':', 1) - except: + except: raise ValueError("Invalid header: %r" % full_header) - value = value.strip() + value = value.strip() if header.lower() not in filtered_headers: - headers_out.append((header, value)) + headers_out.append((header, value)) return headers_out def make_transparent_proxy( diff --git a/paste/reloader.py b/paste/reloader.py index 29b1891..b1b6c74 100644 --- a/paste/reloader.py +++ b/paste/reloader.py @@ -26,7 +26,7 @@ or is run from this .bat file (if you use Windows):: if %errorlevel% == 3 goto repeat or run a monitoring process in Python (``paster serve --reload`` does -this). +this). Use the ``watch_file(filename)`` function to cause a reload/restart for other other non-Python files (e.g., configuration files). If you have diff --git a/paste/request.py b/paste/request.py index 28b1f67..743ab97 100644 --- a/paste/request.py +++ b/paste/request.py @@ -24,7 +24,7 @@ from six.moves.urllib.parse import quote try: # Python 3 from http.cookies import SimpleCookie, CookieError -except ImportError: +except ImportError: # Python 2 from Cookie import SimpleCookie, CookieError @@ -179,7 +179,7 @@ def parse_formvars(environ, include_get_vars=True): old_content_type = environ.get('CONTENT_TYPE') old_content_length = environ.get('CONTENT_LENGTH') environ['CONTENT_LENGTH'] = '0' - environ['CONTENT_TYPE'] = '' + environ['CONTENT_TYPE'] = '' else: input = environ['wsgi.input'] fs = cgi.FieldStorage(fp=input, @@ -375,7 +375,7 @@ class EnvironHeaders(DictMixin): return key[5:].replace('_', '-').title() else: return None - + def __getitem__(self, item): return self.environ[self._trans_name(item)] diff --git a/paste/url.py b/paste/url.py index 87a6e8a..74d0d4d 100644 --- a/paste/url.py +++ b/paste/url.py @@ -136,7 +136,7 @@ class URLResource(object): vars = variabledecode.variable_encode(vars) return vars - + def var(self, **kw): kw = self.coerce_vars(kw) new_vars = self.vars + kw.items() @@ -181,14 +181,14 @@ class URLResource(object): attrs=u.attrs, params=u.original_params) return u - + __div__ = addpath def become(self, OtherClass): return OtherClass(self.url, vars=self.vars, attrs=self.attrs, params=self.original_params) - + def href__get(self): s = self.url if self.vars: @@ -217,7 +217,7 @@ class URLResource(object): ', '.join(['%s=%r' % (n, v) for n, v in self.attrs.items()])) return base + '>' - + def html__get(self): if not self.params.get('tag'): raise ValueError( @@ -250,7 +250,7 @@ class URLResource(object): for an empty tag (like ``<img />``) """ raise NotImplementedError - + def _add_vars(self, vars): raise NotImplementedError @@ -328,7 +328,7 @@ class URL(URLResource): return self.become(JSPopup) js_popup = property(js_popup__get) - + class Image(URLResource): r""" @@ -341,7 +341,7 @@ class Image(URLResource): >>> i.href '/images/foo.png' """ - + default_params = {'tag': 'img'} def __str__(self): @@ -470,4 +470,4 @@ class JSPopup(URLResource): if __name__ == '__main__': import doctest doctest.testmod() - + diff --git a/paste/util/UserDict24.py b/paste/util/UserDict24.py index e5b64f5..5fd9778 100644 --- a/paste/util/UserDict24.py +++ b/paste/util/UserDict24.py @@ -162,6 +162,6 @@ class DictMixin: return cmp(dict(self.iteritems()), other) def __len__(self): return len(self.keys()) - + def __nonzero__(self): return bool(self.iteritems()) diff --git a/paste/util/dateinterval.py b/paste/util/dateinterval.py index 5109e28..80fe347 100644 --- a/paste/util/dateinterval.py +++ b/paste/util/dateinterval.py @@ -7,7 +7,7 @@ years (leap years in particular). Accepts (y)ear, (b)month, (w)eek, (d)ay, (h)our, (m)inute, (s)econd. -Exports only timeEncode and timeDecode functions. +Exports only timeEncode and timeDecode functions. """ import re @@ -33,7 +33,7 @@ timeValues = { timeOrdered = list(timeValues.items()) timeOrdered.sort(key=lambda x: x[1], reverse=True) - + def interval_encode(seconds, include_sign=False): """Encodes a number of seconds (representing a time interval) into a form like 1h2d3s. diff --git a/paste/util/filemixin.py b/paste/util/filemixin.py index 10a9e7c..b06b039 100644 --- a/paste/util/filemixin.py +++ b/paste/util/filemixin.py @@ -50,4 +50,4 @@ class FileMixin(object): for line in lines: self.write(line) - + diff --git a/paste/util/finddata.py b/paste/util/finddata.py index 05c8546..bb7c760 100644 --- a/paste/util/finddata.py +++ b/paste/util/finddata.py @@ -48,7 +48,7 @@ def find_package_data( Note patterns use wildcards, or can be exact paths (including leading ``./``), and all searching is case-insensitive. """ - + out = {} stack = [(convert_path(where), '', package, only_in_packages)] while stack: diff --git a/paste/util/findpackage.py b/paste/util/findpackage.py index 68b5e8b..9d653e5 100644 --- a/paste/util/findpackage.py +++ b/paste/util/findpackage.py @@ -23,4 +23,4 @@ def find_package(dir): raise ValueError( "%s is not under any path found in sys.path" % orig_dir) last_dir = dir - + diff --git a/paste/util/looper.py b/paste/util/looper.py index efe7fdf..dd0c6fd 100644 --- a/paste/util/looper.py +++ b/paste/util/looper.py @@ -26,9 +26,9 @@ import six class looper(object): """ Helper for looping (particularly in templates) - + Use this like:: - + for loop, item in looper(seq): if loop.first: ... @@ -152,4 +152,4 @@ class loop_pos(object): return getter(item) != getter(other) else: return item[getter] != other[getter] - + diff --git a/paste/util/scgiserver.py b/paste/util/scgiserver.py index f65294d..1c86c86 100644 --- a/paste/util/scgiserver.py +++ b/paste/util/scgiserver.py @@ -42,7 +42,7 @@ class SWAP(scgi_server.SCGIHandler): """ app_obj = None prefix = None - + def __init__(self, *args, **kwargs): assert self.app_obj, "must set app_obj" assert self.prefix is not None, "must set prefix" @@ -85,7 +85,7 @@ class SWAP(scgi_server.SCGIHandler): chunks = [] def write(data): chunks.append(data) - + def start_response(status, response_headers, exc_info=None): if exc_info: try: @@ -106,7 +106,7 @@ class SWAP(scgi_server.SCGIHandler): try: for data in result: chunks.append(data) - + # Before the first output, send the stored headers if not headers_set: # Error -- the app never called start_response @@ -115,7 +115,7 @@ class SWAP(scgi_server.SCGIHandler): chunks = ["XXX start_response never called"] else: status, response_headers = headers_sent[:] = headers_set - + output.write('Status: %s\r\n' % status) for header in response_headers: output.write('%s: %s\r\n' % header) diff --git a/paste/util/template.py b/paste/util/template.py index afeb353..981816b 100644 --- a/paste/util/template.py +++ b/paste/util/template.py @@ -251,7 +251,7 @@ class Template(object): '(no default_encoding provided)' % value) value = value.encode(self.default_encoding) return value - + def _add_line_info(self, msg, pos): msg = "%s at line %s column %s" % ( @@ -479,7 +479,7 @@ def trim_lex(tokens): next = next[m.end():] tokens[i+1] = next return tokens - + def find_position(string, index): """Given a string and index, return (line, column)""" @@ -506,7 +506,7 @@ def parse(s, name=None): [('cond', (1, 3), ('if', (1, 3), 'x', ['a']), ('elif', (1, 12), 'y', ['b']), ('else', (1, 23), None, ['c']))] Some exceptions:: - + >>> parse('{{continue}}') Traceback (most recent call last): ... @@ -627,7 +627,7 @@ def parse_one_cond(tokens, name, context): return part, tokens next, tokens = parse_expr(tokens, name, context) content.append(next) - + def parse_for(tokens, name, context): first, pos = tokens[0] tokens = tokens[1:] @@ -755,5 +755,5 @@ def fill_command(args=None): if __name__ == '__main__': from paste.util.template import fill_command fill_command() - - + + diff --git a/paste/util/threadedprint.py b/paste/util/threadedprint.py index ae7dc0d..e69993e 100644 --- a/paste/util/threadedprint.py +++ b/paste/util/threadedprint.py @@ -114,7 +114,7 @@ class PrintCatcher(filemixin.FileMixin): self._default.read(*args) else: catchers[name].read(*args) - + def _writedefault(self, name, v): self._default.write(v) diff --git a/paste/wsgilib.py b/paste/wsgilib.py index 1234ef9..73ed4d3 100644 --- a/paste/wsgilib.py +++ b/paste/wsgilib.py @@ -289,7 +289,7 @@ def raw_interactive(application, path='', raise_on_wsgi_error=False, 'SCRIPT_NAME': '', # may be empty if app is at the root 'PATH_INFO': '', # may be empty if at root of app 'SERVER_NAME': 'localhost', # always mandatory - 'SERVER_PORT': '80', # always mandatory + 'SERVER_PORT': '80', # always mandatory 'SERVER_PROTOCOL': 'HTTP/1.0', # mandatory wsgi variables 'wsgi.version': (1, 0), @@ -435,7 +435,7 @@ def capture_output(environ, start_response, application): Sends status and header, but *not* body. Returns (status, headers, body). Typically this is used like: - + .. code-block:: python def dehtmlifying_middleware(application): @@ -486,7 +486,7 @@ def intercept_output(environ, application, conditional=None, ``capture_output``) Typically this is used like: - + .. code-block:: python def dehtmlifying_middleware(application): @@ -508,7 +508,7 @@ def intercept_output(environ, application, conditional=None, ``start_response`` will be called and ``(None, None, app_iter)`` will be returned. You must detect that in your code and return the app_iter, like: - + .. code-block:: python def dehtmlifying_middleware(application): @@ -593,4 +593,4 @@ for _name in __all__: if __name__ == '__main__': import doctest doctest.testmod() - + diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py index 9b614ec..290179d 100644 --- a/paste/wsgiwrappers.py +++ b/paste/wsgiwrappers.py @@ -84,18 +84,18 @@ class WSGIRequest(object): The class variable ``defaults`` specifies default values for ``charset``, ``errors``, and ``langauge``. These can be overridden for the current request via the registry. - + The ``language`` default value is considered the fallback during i18n translations to ensure in odd cases that mixed languages don't occur should the ``language`` file contain the string but not another language in the accepted languages list. The ``language`` value only applies when getting a list of accepted languages from the HTTP Accept header. - + This behavior is duplicated from Aquarium, and may seem strange but is - very useful. Normally, everything in the code is in "en-us". However, + very useful. Normally, everything in the code is in "en-us". However, the "en-us" translation catalog is usually empty. If the user requests ``["en-us", "zh-cn"]`` and a translation isn't found for a string in - "en-us", you don't want gettext to fallback to "zh-cn". You want it to + "en-us", you don't want gettext to fallback to "zh-cn". You want it to just use the string itself. Hence, if a string isn't found in the ``language`` catalog, the string in the source code will be used. @@ -112,7 +112,7 @@ class WSGIRequest(object): self.environ = environ # This isn't "state" really, since the object is derivative: self.headers = EnvironHeaders(environ) - + defaults = self.defaults._current_obj() self.charset = defaults.get('charset') if self.charset: @@ -124,7 +124,7 @@ class WSGIRequest(object): self.errors = defaults.get('errors', 'strict') self.decode_param_names = defaults.get('decode_param_names', False) self._languages = None - + body = environ_getter('wsgi.input') scheme = environ_getter('wsgi.url_scheme') method = environ_getter('REQUEST_METHOD') @@ -143,12 +143,12 @@ class WSGIRequest(object): else: return {} urlvars = property(urlvars, doc=urlvars.__doc__) - + def is_xhr(self): """Returns a boolean if X-Requested-With is present and a XMLHttpRequest""" return self.environ.get('HTTP_X_REQUESTED_WITH', '') == 'XMLHttpRequest' is_xhr = property(is_xhr, doc=is_xhr.__doc__) - + def host(self): """Host name provided in HTTP_HOST, with fall-back to SERVER_NAME""" return self.environ.get('HTTP_HOST', self.environ.get('SERVER_NAME')) @@ -156,7 +156,7 @@ class WSGIRequest(object): def languages(self): """Return a list of preferred languages, most preferred first. - + The list may be empty. """ if self._languages is not None: @@ -173,7 +173,7 @@ class WSGIRequest(object): self._languages = langs return self._languages languages = property(languages, doc=languages.__doc__) - + def _GET(self): return parse_dict_querystring(self.environ) @@ -253,7 +253,7 @@ class WSGIRequest(object): """Dictionary of cookies keyed by cookie name. Just a plain dictionary, may be empty but not None. - + """ return get_cookie_dict(self.environ) cookies = property(cookies, doc=cookies.__doc__) @@ -270,7 +270,7 @@ class WSGIRequest(object): def match_accept(self, mimetypes): """Return a list of specified mime-types that the browser's HTTP Accept header allows in the order provided.""" - return desired_matches(mimetypes, + return desired_matches(mimetypes, self.environ.get('HTTP_ACCEPT', '*/*')) def __repr__(self): @@ -300,7 +300,7 @@ class WSGIResponse(object): """ defaults = StackedObjectProxy( - default=dict(content_type='text/html', charset='utf-8', + default=dict(content_type='text/html', charset='utf-8', errors='strict', headers={'Cache-Control':'no-cache'}) ) def __init__(self, content='', mimetype=None, code=200): @@ -335,14 +335,14 @@ class WSGIResponse(object): return '\n'.join(['%s: %s' % (key, value) for key, value in self.headers.headeritems()]) \ + '\n\n' + content - + def __call__(self, environ, start_response): """Convenience call to return output and set status information - + Conforms to the WSGI interface for calling purposes only. - + Example usage: - + .. code-block:: python def wsgi_app(environ, start_response): @@ -350,7 +350,7 @@ class WSGIResponse(object): response.write("Hello world") response.headers['Content-Type'] = 'latin1' return response(environ, start_response) - + """ status_text = STATUS_CODE_TEXT[self.status_code] status = '%s %s' % (self.status_code, status_text) @@ -364,7 +364,7 @@ class WSGIResponse(object): elif is_file: return iter(lambda: self.content.read(), '') return self.get_content() - + def determine_charset(self): """ Determine the encoding as specified by the Content-Type's charset @@ -373,7 +373,7 @@ class WSGIResponse(object): charset_match = _CHARSET_RE.search(self.headers.get('Content-Type', '')) if charset_match: return charset_match.group(1) - + def has_header(self, header): """ Case-insensitive check for a header @@ -434,7 +434,7 @@ class WSGIResponse(object): return encode_unicode_app_iter(self.content, charset, self.errors) else: return self.content - + def wsgi_response(self): """ Return this WSGIResponse as a tuple of WSGI formatted data, including: @@ -446,12 +446,12 @@ class WSGIResponse(object): for c in self.cookies.values(): response_headers.append(('Set-Cookie', c.output(header=''))) return status, response_headers, self.get_content() - + # The remaining methods partially implement the file-like object interface. # See http://docs.python.org/lib/bltin-file-objects.html def write(self, content): if not self._is_str_iter: - raise IOError("This %s instance's content is not writable: (content " + raise IOError("This %s instance's content is not writable: (content " 'is an iterator)' % self.__class__.__name__) self.content.append(content) diff --git a/tests/test_auth/test_auth_cookie.py b/tests/test_auth/test_auth_cookie.py index d1db981..3bff2d8 100644 --- a/tests/test_auth/test_auth_cookie.py +++ b/tests/test_auth/test_auth_cookie.py @@ -15,7 +15,7 @@ from paste.auth import cookie from paste.wsgilib import raw_interactive, dump_environ from paste.response import header_value from paste.httpexceptions import * - + def build(application,setenv, *args, **kwargs): def setter(environ, start_response): save = environ['paste.auth.cookie'].append diff --git a/tests/test_cgitb_catcher.py b/tests/test_cgitb_catcher.py index 788ede2..c2c6632 100644 --- a/tests/test_cgitb_catcher.py +++ b/tests/test_cgitb_catcher.py @@ -11,7 +11,7 @@ def do_request(app, expect_status=500): res = testapp.get('', status=expect_status, expect_errors=True) return res - + ############################################################ ## Applications that raise exceptions @@ -69,7 +69,7 @@ def test_iter_app(): print(res) assert 'None raises error' in res assert 'yielder' in res - - - + + + diff --git a/tests/test_config.py b/tests/test_config.py index ea6be75..a23238e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -55,7 +55,7 @@ def test_process_config(request_app=test_request_config): assert CONFIG[test_key] == 'bar' assert CONFIG['process_var'] == 'foo' CONFIG.pop_process_config() - + assert_raises(AttributeError, lambda: 'process_var' not in CONFIG) assert_raises(IndexError, CONFIG.pop_process_config) diff --git a/tests/test_exceptions/test_error_middleware.py b/tests/test_exceptions/test_error_middleware.py index a34de73..d8fd802 100644 --- a/tests/test_exceptions/test_error_middleware.py +++ b/tests/test_exceptions/test_error_middleware.py @@ -19,7 +19,7 @@ def do_request(app, expect_status=500): def clear_middleware(app): """ The fixture sets paste.throw_errors, which suppresses exactly what - we want to test in this case. This wrapper also strips exc_info + we want to test in this case. This wrapper also strips exc_info on the *first* call to start_response (but not the second, or subsequent calls. """ @@ -34,7 +34,7 @@ def clear_middleware(app): del environ['paste.throw_errors'] return app(environ, replacement) return clear_throw_errors - + ############################################################ ## Applications that raise exceptions @@ -81,7 +81,7 @@ def test_makes_exception(): def test_unicode_exception(): res = do_request(unicode_bad_app) - + def test_start_res(): res = do_request(start_response_app) @@ -101,7 +101,7 @@ def test_iter_app(): #print res assert 'None raises error' in res assert 'yielder' in res - - - + + + diff --git a/tests/test_import_string.py b/tests/test_import_string.py index 96526ac..262cbdd 100644 --- a/tests/test_import_string.py +++ b/tests/test_import_string.py @@ -11,6 +11,6 @@ def test_simple(): def test_complex(): assert eval_import('sys:version') is sys.version assert eval_import('os:getcwd()') == os.getcwd() - assert (eval_import('sys:version.split()[0]') == + assert (eval_import('sys:version.split()[0]') == sys.version.split()[0]) - + diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 36d16b5..44db9f3 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -9,4 +9,4 @@ def test_paste_website(): app = TestApp(app) res = app.get('/') assert 'documentation' in res - + diff --git a/tests/test_recursive.py b/tests/test_recursive.py index 114592e..8d2f96b 100644 --- a/tests/test_recursive.py +++ b/tests/test_recursive.py @@ -43,15 +43,15 @@ def forward(app): else: raise AssertionError('Failed to detect forwarding loop') -def test_ForwardRequest_url(): +def test_ForwardRequest_url(): class TestForwardRequestMiddleware(Middleware): def __call__(self, environ, start_response): if environ['PATH_INFO'] != '/not_found': return self.app(environ, start_response) raise ForwardRequestException(self.url) forward(TestForwardRequestMiddleware(error_docs_app)) - -def test_ForwardRequest_environ(): + +def test_ForwardRequest_environ(): class TestForwardRequestMiddleware(Middleware): def __call__(self, environ, start_response): if environ['PATH_INFO'] != '/not_found': @@ -59,11 +59,11 @@ def test_ForwardRequest_environ(): environ['PATH_INFO'] = self.url raise ForwardRequestException(environ=environ) forward(TestForwardRequestMiddleware(error_docs_app)) - -def test_ForwardRequest_factory(): - + +def test_ForwardRequest_factory(): + from paste.errordocument import StatusKeeper - + class TestForwardRequestMiddleware(Middleware): def __call__(self, environ, start_response): if environ['PATH_INFO'] != '/not_found': @@ -96,7 +96,7 @@ def test_ForwardRequest_factory(): raise AssertionError('Failed to detect forwarding loop') # Test Deprecated Code -def test_ForwardRequestException(): +def test_ForwardRequestException(): class TestForwardRequestExceptionMiddleware(Middleware): def __call__(self, environ, start_response): if environ['PATH_INFO'] != '/not_found': diff --git a/tests/test_registry.py b/tests/test_registry.py index fdbc26c..af3a389 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -35,7 +35,7 @@ class RegistryUsingApp(object): self.var = var self.value = value self.raise_exc = raise_exc - + def __call__(self, environ, start_response): if 'paste.registry' in environ: environ['paste.registry'].register(self.var, self.value) @@ -50,7 +50,7 @@ class RegistryUsingIteratorApp(object): def __init__(self, var, value): self.var = var self.value = value - + def __call__(self, environ, start_response): if 'paste.registry' in environ: environ['paste.registry'].register(self.var, self.value) @@ -65,7 +65,7 @@ class RegistryMiddleMan(object): self.var = var self.value = value self.depth = depth - + def __call__(self, environ, start_response): if 'paste.registry' in environ: environ['paste.registry'].register(self.var, self.value) @@ -85,7 +85,7 @@ class RegistryMiddleMan(object): app_response.extend(['\nAppended by middleware!\nAppendValue at \ depth %s is %s' % (self.depth, str(regobj))]) return app_response - + def test_simple(): app = TestApp(simpleapp) @@ -150,7 +150,7 @@ def test_really_deep_registry(): for depth in valuelist: assert "AppendValue at depth %s is {'%s': %s}" % \ (depth, keylist[depth], depth) in res - + def test_iterating_response(): obj = {'hi':'people'} secondobj = {'bye':'friends'} diff --git a/tests/test_request.py b/tests/test_request.py index 3d882ed..f5b59d6 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -21,7 +21,7 @@ def test_gets(): res = app.get('/') assert 'Hello' in res assert "get is MultiDict([])" in res - + res = app.get('/?name=george') res.mustcontain("get is MultiDict([('name', 'george')])") res.mustcontain("Val is george") @@ -30,7 +30,7 @@ def test_language_parsing(): app = TestApp(simpleapp) res = app.get('/') assert "The languages are: ['en-us']" in res - + res = app.get('/', headers={'Accept-Language':'da, en-gb;q=0.8, en;q=0.7'}) assert "languages are: ['da', 'en-gb', 'en', 'en-us']" in res @@ -41,10 +41,10 @@ def test_mime_parsing(): app = TestApp(simpleapp) res = app.get('/', headers={'Accept':'text/html'}) assert "accepttypes is: ['text/html']" in res - + res = app.get('/', headers={'Accept':'application/xml'}) assert "accepttypes is: ['application/xml']" in res - + res = app.get('/', headers={'Accept':'application/xml,*/*'}) assert "accepttypes is: ['text/html', 'application/xml']" in res diff --git a/tests/test_response.py b/tests/test_response.py index d4d4b65..71f6f97 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -8,4 +8,4 @@ def test_replace_header(): replace_header(h, 'Content-Type', 'text/html') assert ('content-type', 'text/html') in h assert ('content-type', 'text/plain') not in h - + diff --git a/tests/test_session.py b/tests/test_session.py index 621d284..ca4de0c 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -26,7 +26,7 @@ def wsgi_app(environ, start_response): return ['foo'] wsgi_app = SessionMiddleware(wsgi_app) - + def test_app1(): app = TestApp(wsgi_app) res = app.get('/get1') @@ -48,5 +48,5 @@ def test_app2(): assert res.body == 'fluff' res = app.get('/get2') assert res.body == 'fluff' - - + + diff --git a/tests/test_wsgiwrappers.py b/tests/test_wsgiwrappers.py index b552f86..0448c69 100644 --- a/tests/test_wsgiwrappers.py +++ b/tests/test_wsgiwrappers.py @@ -42,7 +42,7 @@ def test_wsgirequest_charset(): # Tanaka, '田中' app = TestApp(AssertApp(assertfunc=valid_name(u'田中', encoding='UTF-8'))) res = app.get('/?name=%E7%94%B0%E4%B8%AD') - + # Nippon (Japan), '日本' app = TestApp(AssertApp(assertfunc=valid_name(u'日本', encoding='UTF-8', post=True))) diff --git a/tests/urlparser_data/hook/app.py b/tests/urlparser_data/hook/app.py index d2714e5..a96866c 100644 --- a/tests/urlparser_data/hook/app.py +++ b/tests/urlparser_data/hook/app.py @@ -2,4 +2,4 @@ def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html')]) return ['user: %s' % environ['app.user']] - + diff --git a/tests/urlparser_data/python/simpleapp.py b/tests/urlparser_data/python/simpleapp.py index cbef9f1..e13bb3e 100644 --- a/tests/urlparser_data/python/simpleapp.py +++ b/tests/urlparser_data/python/simpleapp.py @@ -3,4 +3,4 @@ def application(environ, start_response): ('test-header', 'TEST!')]) return ['test1'] - + diff --git a/tests/urlparser_data/python/sub/simpleapp.py b/tests/urlparser_data/python/sub/simpleapp.py index fd90966..ac83a56 100644 --- a/tests/urlparser_data/python/sub/simpleapp.py +++ b/tests/urlparser_data/python/sub/simpleapp.py @@ -3,4 +3,4 @@ def application(environ, start_response): ('test-header', 'TEST!')]) return ['subsimple'] - + |