summaryrefslogtreecommitdiff
path: root/paste/webkit/test_wkfixture.py
diff options
context:
space:
mode:
Diffstat (limited to 'paste/webkit/test_wkfixture.py')
-rw-r--r--paste/webkit/test_wkfixture.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/paste/webkit/test_wkfixture.py b/paste/webkit/test_wkfixture.py
deleted file mode 100644
index 790a099..0000000
--- a/paste/webkit/test_wkfixture.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
-Test fixture for Paste/WebKit testing.
-
-Maybe look at paste.tests.fixture as an alternative to this
-"""
-
-from cStringIO import StringIO
-from paste import recursive
-from paste import session
-from paste import httpexceptions
-from paste import lint
-from paste import wsgilib
-
-_default_environ = {
- 'SCRIPT_NAME': '',
- 'SERVER_NAME': 'localhost',
- 'SERVER_PORT': '80',
- 'REQUEST_METHOD': 'GET',
- 'HTTP_HOST': 'localhost:80',
- 'CONTENT_LENGTH': '0',
- 'wsgi.input': StringIO(''),
- 'wsgi.version': (1, 0),
- 'wsgi.multithread': False,
- 'wsgi.multiprocess': False,
- 'wsgi.run_once': False,
-}
-
-def stack(application):
- """
- Creates a WebKit stack, except with a fixed application and
- no URLParser.
- """
- return recursive.middleware(
- lint.middleware(
- httpexceptions.middleware(
- lint.middleware(
- session.middleware(
- lint.middleware(application))))))
-
-def in_request(application, **kw):
- """
- Used to wrap a function in an application invokation, used like::
-
- @in_request(my_app, path_info='/whatever',
- wsgi__input='post-data',
- REQUEST_METHOD='POST')
- def test_this(output, **kw):
- assert 'I got post-data' in output
-
- The wrapped function received several keyword arguments, and in
- the future there may be more, so a **kw is required so that
- extra arguments may be ignored.
- """
- def decorator(func):
- def replacement_func(*inner_args, **inner_kw):
- # Note, *inner_args and **inner_kw are intended for use
- # with @param or other py.test parameterizers
- app = stack(application)
- status, headers, output, errors = wsgilib.raw_interactive(
- app, **kw)
- return func(status=status, headers=headers, output=output,
- errors=errors, application=application,
- *inner_args,
- **inner_kw)
- return replacement_func
- return decorator