summaryrefslogtreecommitdiff
path: root/cherrypy/test
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/test')
-rw-r--r--cherrypy/test/__init__.py13
-rw-r--r--cherrypy/test/benchmark.py5
-rw-r--r--cherrypy/test/modpy.py2
-rw-r--r--cherrypy/test/test.py4
-rw-r--r--cherrypy/test/test_caching.py6
-rw-r--r--cherrypy/test/test_config.py32
-rw-r--r--cherrypy/test/test_conn.py10
-rw-r--r--cherrypy/test/test_core.py33
-rw-r--r--cherrypy/test/test_decodingencoding.py3
-rw-r--r--cherrypy/test/test_etags.py15
-rw-r--r--cherrypy/test/test_gzip.py11
-rw-r--r--cherrypy/test/test_http.py8
-rw-r--r--cherrypy/test/test_objectmapping.py7
-rw-r--r--cherrypy/test/test_proxy.py9
-rw-r--r--cherrypy/test/test_response_headers.py5
-rwxr-xr-xcherrypy/test/test_session.py5
-rw-r--r--cherrypy/test/test_sessionauthenticate.py5
-rw-r--r--cherrypy/test/test_states.py19
-rw-r--r--cherrypy/test/test_states_demo.py5
-rw-r--r--cherrypy/test/test_static.py8
-rw-r--r--cherrypy/test/test_tools.py9
-rw-r--r--cherrypy/test/test_tutorials.py6
-rw-r--r--cherrypy/test/test_virtualhost.py13
-rw-r--r--cherrypy/test/test_wsgiapps.py5
-rw-r--r--cherrypy/test/test_xmlrpc.py6
25 files changed, 68 insertions, 176 deletions
diff --git a/cherrypy/test/__init__.py b/cherrypy/test/__init__.py
index 49f2e1ea..eef14d44 100644
--- a/cherrypy/test/__init__.py
+++ b/cherrypy/test/__init__.py
@@ -3,16 +3,3 @@
Run test.py to exercise all tests.
"""
-# Ideas for future tests:
-# - test if tabs and whitespaces are handled correctly in source file (option -W)
-# - test if absolute pathnames work fine on windows
-# - test sessions
-# - test threading server
-# - test forking server
-# - test process pooling server
-# - test SSL
-# - test compilator errors
-# - test abstract classes
-# - test hidden classes
-# ...
-
diff --git a/cherrypy/test/benchmark.py b/cherrypy/test/benchmark.py
index f3a839c0..a8186651 100644
--- a/cherrypy/test/benchmark.py
+++ b/cherrypy/test/benchmark.py
@@ -60,13 +60,12 @@ class Root:
cherrypy.config.update({
- 'log_to_screen': False,
-## 'log_file': os.path.join(curdir, "bench.log"),
+ 'log.error.file': '',
'environment': 'production',
'server.socket_host': 'localhost',
'server.socket_port': 8080,
'server.max_request_header_size': 0,
- 'server.max_request_body_size': 0,
+ 'request.max_body_size': 0,
})
appconf = {
diff --git a/cherrypy/test/modpy.py b/cherrypy/test/modpy.py
index 2d9f5ef1..6fa8a7d0 100644
--- a/cherrypy/test/modpy.py
+++ b/cherrypy/test/modpy.py
@@ -110,7 +110,7 @@ def wsgisetup(req):
import cherrypy
cherrypy.config.update({
- "log_file": os.path.join(curdir, "test.log"),
+ "log.error.file": os.path.join(curdir, "test.log"),
"environment": "production",
})
cherrypy.engine.start(blocking=False)
diff --git a/cherrypy/test/test.py b/cherrypy/test/test.py
index 7044567f..54225cbd 100644
--- a/cherrypy/test/test.py
+++ b/cherrypy/test/test.py
@@ -43,9 +43,7 @@ class TestHarness(object):
baseconf = {'server.socket_host': '127.0.0.1',
'server.socket_port': self.port,
'server.thread_pool': 10,
- 'log_to_screen': False,
- 'environment': "production",
- 'show_tracebacks': True,
+ 'environment': "test_suite",
}
baseconf.update(conf or {})
diff --git a/cherrypy/test/test_caching.py b/cherrypy/test/test_caching.py
index 44533423..54665914 100644
--- a/cherrypy/test/test_caching.py
+++ b/cherrypy/test/test_caching.py
@@ -58,11 +58,7 @@ def setup_server():
cherrypy.tree.mount(Root())
cherrypy.tree.mount(UnCached(), "/expires")
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_config.py b/cherrypy/test/test_config.py
index 03e59ce6..b7fe3cc7 100644
--- a/cherrypy/test/test_config.py
+++ b/cherrypy/test/test_config.py
@@ -34,28 +34,17 @@ def setup_server():
bar.exposed = True
bar._cp_config = {'foo': 'this3', 'bax': 'this4'}
- class Env:
+ class Another:
def index(self, key):
return str(cherrypy.config.get(key, "None"))
index.exposed = True
- prod = index
- embed = index
root = Root()
root.foo = Foo()
cherrypy.tree.mount(root)
-
- cherrypy.config.update({'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
-
- _env_conf = {'/': {'environment': 'development'},
- '/prod': {'environment': 'production'},
- '/embed': {'environment': 'embedded'},
- }
- cherrypy.tree.mount(Env(), "/env", _env_conf)
+ cherrypy.tree.mount(Another(), "/another")
+ cherrypy.config.update({'environment': 'test_suite'})
# Shortcut syntax--should get put in the "global" bucket
cherrypy.config.update({'luxuryyacht': 'throatwobblermangrove'})
@@ -78,23 +67,12 @@ class ConfigTests(helper.CPWebCase):
('/foo/', 'bax', 'None'),
('/foo/bar', 'baz', 'that2'),
('/foo/nex', 'baz', 'that2'),
- # If 'foo' == 'this', then the mount point '/env' leaks into '/'.
- ('/env/prod','foo', 'None'),
+ # If 'foo' == 'this', then the mount point '/another' leaks into '/'.
+ ('/another/','foo', 'None'),
]
for path, key, expected in tests:
self.getPage(path + "?key=" + key)
self.assertBody(expected)
-
- def testEnvironments(self):
- for key, val in cherrypy.config.environments['development'].iteritems():
- self.getPage("/env/?key=" + key)
- self.assertBody(str(val))
- for key, val in cherrypy.config.environments['production'].iteritems():
- self.getPage("/env/prod/?key=" + key)
- self.assertBody(str(val))
- for key, val in cherrypy.config.environments['embedded'].iteritems():
- self.getPage("/env/embed/?key=" + key)
- self.assertBody(str(val))
if __name__ == '__main__':
diff --git a/cherrypy/test/test_conn.py b/cherrypy/test/test_conn.py
index 47c95566..75120324 100644
--- a/cherrypy/test/test_conn.py
+++ b/cherrypy/test/test_conn.py
@@ -28,7 +28,7 @@ def setup_server():
for x in xrange(10):
yield str(x)
stream.exposed = True
- stream._cp_config = {'stream_response': True}
+ stream._cp_config = {'response.stream': True}
def upload(self):
return ("thanks for '%s' (%s)" %
@@ -38,10 +38,8 @@ def setup_server():
cherrypy.tree.mount(Root())
cherrypy.config.update({
- 'log_to_screen': False,
- 'server.max_request_body_size': 100,
- 'show_tracebacks': True,
- 'environment': 'production',
+ 'request.max_body_size': 100,
+ 'environment': 'test_suite',
})
@@ -222,7 +220,7 @@ class ConnectionTests(helper.CPWebCase):
self.assertStatus('200 OK')
self.assertBody("thanks for 'xx\r\nxxxxyyyyy' (application/x-json)")
- # Try a chunked request that exceeds max_request_body_size.
+ # Try a chunked request that exceeds request.max_body_size.
# Note that the delimiters and trailer are included.
body = "5f\r\n" + ("x" * 95) + "\r\n0\r\n\r\n"
conn.putrequest("POST", "/upload", skip_host=True)
diff --git a/cherrypy/test/test_core.py b/cherrypy/test/test_core.py
index 81acf3f2..ff11bfed 100644
--- a/cherrypy/test/test_core.py
+++ b/cherrypy/test/test_core.py
@@ -219,23 +219,23 @@ def setup_server():
raise ValueError()
# We support Python 2.3, but the @-deco syntax would look like this:
- # @cherrypy.config.wrap(stream_response=True)
+ # @cherrypy.config.wrap(**{"response.stream": True})
def page_streamed(self):
yield "word up"
raise ValueError()
yield "very oops"
- page_streamed = cherrypy.config.wrap(stream_response=True)(page_streamed)
- assert(page_streamed._cp_config == {'stream_response': True})
+ page_streamed = cherrypy.config.wrap(**{"response.stream": True})(page_streamed)
+ assert(page_streamed._cp_config == {'response.stream': True})
def cause_err_in_finalize(self):
# Since status must start with an int, this should error.
cherrypy.response.status = "ZOO OK"
- cause_err_in_finalize._cp_config = {'show_tracebacks': False}
+ cause_err_in_finalize._cp_config = {'request.show_tracebacks': False}
def rethrow(self):
"""Test that an error raised here will be thrown out to the server."""
raise ValueError()
- rethrow._cp_config = {'throw_errors': True}
+ rethrow._cp_config = {'request.throw_errors': True}
class Ranges(Test):
@@ -370,19 +370,14 @@ def setup_server():
return u'Wrong login/password'
cherrypy.config.update({
- 'log_to_screen': False,
- 'log_file': log_file,
- 'environment': 'production',
- 'show_tracebacks': True,
- 'server.max_request_body_size': 200,
+ 'log.error.file': log_file,
+ 'environment': 'test_suite',
+ 'request.max_body_size': 200,
'server.max_request_header_size': 500,
})
-
- def expand_methods():
- cherrypy.request.methods_with_bodies = ("POST", "PUT", "PROPFIND")
appconf = {
- '/': {'log_access_file': log_access_file},
- '/method': {'hooks.on_start_resource': expand_methods},
+ '/': {'log.access.file': log_access_file},
+ '/method': {'request.methods_with_bodies': ("POST", "PUT", "PROPFIND")},
}
cherrypy.tree.mount(root, conf=appconf)
@@ -643,10 +638,10 @@ class CoreRequestHandlingTest(helper.CPWebCase):
"In addition, the custom error page failed:\n<br />"
"[Errno 2] No such file or directory: 'nonexistent.html'")
self.assertInBody(msg)
-##
-## # Test throw_errors (ticket #186).
-## self.getPage("/error/rethrow")
-## self.assertBody("THROWN ERROR: ValueError")
+
+ # Test throw_errors (ticket #186).
+ self.getPage("/error/rethrow")
+ self.assertInBody("raise ValueError()")
def testRanges(self):
self.getPage("/ranges/get_ranges", [('Range', 'bytes=3-6')])
diff --git a/cherrypy/test/test_decodingencoding.py b/cherrypy/test/test_decodingencoding.py
index ab783cae..9e5fdacc 100644
--- a/cherrypy/test/test_decodingencoding.py
+++ b/cherrypy/test/test_decodingencoding.py
@@ -21,8 +21,7 @@ def setup_server():
cherrypy.tree.mount(Root())
cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
+ 'environment': 'test_suite',
'tools.encode.on': True,
'tools.decode.on': True,
})
diff --git a/cherrypy/test/test_etags.py b/cherrypy/test/test_etags.py
index 6c40e611..da191719 100644
--- a/cherrypy/test/test_etags.py
+++ b/cherrypy/test/test_etags.py
@@ -14,19 +14,10 @@ def setup_server():
raise cherrypy.HTTPError(412)
fail.exposed = True
- conf = {
- '/': {
- 'tools.etags.on': True,
- 'tools.etags.autotags': True,
- },
- }
+ conf = {'/': {'tools.etags.on': True,
+ 'tools.etags.autotags': True}}
cherrypy.tree.mount(Root(), conf=conf)
-
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_gzip.py b/cherrypy/test/test_gzip.py
index 17b50c59..aac8db91 100644
--- a/cherrypy/test/test_gzip.py
+++ b/cherrypy/test/test_gzip.py
@@ -23,16 +23,11 @@ def setup_server():
raise IndexError()
yield "Here be dragons"
noshow_stream.exposed = True
- noshow_stream._cp_config = {'stream_response': True}
+ noshow_stream._cp_config = {'response.stream': True}
cherrypy.tree.mount(Root())
- cherrypy.config.update({
- 'global': {'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- 'tools.gzip.on': True,
- },
- })
+ cherrypy.config.update({'environment': 'test_suite',
+ 'tools.gzip.on': True})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_http.py b/cherrypy/test/test_http.py
index ab45fa07..91a7d7a4 100644
--- a/cherrypy/test/test_http.py
+++ b/cherrypy/test/test_http.py
@@ -35,13 +35,7 @@ def setup_server():
len(gc.get_referrers(data)))
gc_stats.exposed = True
cherrypy.tree.mount(Root())
-
- cherrypy.config.update({
- 'global': {'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- },
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_objectmapping.py b/cherrypy/test/test_objectmapping.py
index 1540a4fe..33ad1468 100644
--- a/cherrypy/test/test_objectmapping.py
+++ b/cherrypy/test/test_objectmapping.py
@@ -126,14 +126,11 @@ def setup_server():
for url in script_names:
d = cherrypy._cprequest.MethodDispatcher()
conf = {'/': {'user': (url or "/").split("/")[-2]},
- '/bymethod': {'dispatch': d},
+ '/bymethod': {'request.dispatch': d},
}
cherrypy.tree.mount(Root(), url, conf)
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': "production",
- })
+ cherrypy.config.update({'environment': "test_suite"})
class Isolated:
diff --git a/cherrypy/test/test_proxy.py b/cherrypy/test/test_proxy.py
index 90668ca8..731cc047 100644
--- a/cherrypy/test/test_proxy.py
+++ b/cherrypy/test/test_proxy.py
@@ -21,11 +21,10 @@ def setup_server():
cherrypy.tree.mount(Root())
cherrypy.config.update({
- 'environment': 'production',
- 'log_to_screen': False,
- 'tools.proxy.on': True,
- 'tools.proxy.base': 'http://www.mydomain.com',
- })
+ 'environment': 'test_suite',
+ 'tools.proxy.on': True,
+ 'tools.proxy.base': 'http://www.mydomain.com',
+ })
from cherrypy.test import helper
diff --git a/cherrypy/test/test_response_headers.py b/cherrypy/test/test_response_headers.py
index 44cd1528..f3346447 100644
--- a/cherrypy/test/test_response_headers.py
+++ b/cherrypy/test/test_response_headers.py
@@ -23,10 +23,7 @@ def setup_server():
}
cherrypy.tree.mount(Root())
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py
index e8695df2..1943f9d0 100755
--- a/cherrypy/test/test_session.py
+++ b/cherrypy/test/test_session.py
@@ -45,10 +45,7 @@ def setup_server():
index.exposed = True
cherrypy.tree.mount(Root())
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_sessionauthenticate.py b/cherrypy/test/test_sessionauthenticate.py
index c53fb59f..ed269d28 100644
--- a/cherrypy/test/test_sessionauthenticate.py
+++ b/cherrypy/test/test_sessionauthenticate.py
@@ -22,10 +22,7 @@ def setup_server():
index.exposed = True
cherrypy.tree.mount(Test())
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_states.py b/cherrypy/test/test_states.py
index 1ff13e9d..dfb530a6 100644
--- a/cherrypy/test/test_states.py
+++ b/cherrypy/test/test_states.py
@@ -34,14 +34,13 @@ class Root:
def block_implicit(self):
raise cherrypy.InternalRedirect("/block_implicit")
block_implicit.exposed = True
- block_implicit._cp_config = {'recursive_redirect': True}
+ block_implicit._cp_config = {'request.recursive_redirect': True}
cherrypy.tree.mount(Root())
cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- 'deadlock_poll_freq': 1,
- 'deadlock_timeout': 2,
+ 'environment': 'test_suite',
+ 'deadlock.poll_freq': 1,
+ 'deadlock.timeout': 2,
})
class Dependency:
@@ -298,10 +297,7 @@ def run_all(host, port):
conf = {'server.socket_host': host,
'server.socket_port': port,
'server.thread_pool': 10,
- 'log_to_screen': False,
- 'log_config': False,
- 'environment': "production",
- 'show_tracebacks': True,
+ 'environment': "test_suite",
}
def _run(server):
print
@@ -315,10 +311,7 @@ def run_localhosts(port):
conf = {'server.socket_host': host,
'server.socket_port': port,
'server.thread_pool': 10,
- 'log_to_screen': False,
- 'log_config': False,
- 'environment': "production",
- 'show_tracebacks': True,
+ 'environment': "test_suite",
}
def _run(server):
print
diff --git a/cherrypy/test/test_states_demo.py b/cherrypy/test/test_states_demo.py
index 55c046fe..d2eceb7f 100644
--- a/cherrypy/test/test_states_demo.py
+++ b/cherrypy/test/test_states_demo.py
@@ -23,8 +23,7 @@ class Root:
if __name__ == '__main__':
cherrypy.config.update({"server.socket_host": sys.argv[1],
"server.socket_port": int(sys.argv[2]),
- "log_to_screen": False,
- "environment": "development",
+ "log.screen": False,
})
cherrypy.quickstart(Root())
- \ No newline at end of file
+ \ No newline at end of file
diff --git a/cherrypy/test/test_static.py b/cherrypy/test/test_static.py
index 3f3c0433..16b10781 100644
--- a/cherrypy/test/test_static.py
+++ b/cherrypy/test/test_static.py
@@ -44,16 +44,12 @@ def setup_server():
},
'/error': {
'tools.staticdir.on': True,
- 'show_tracebacks': True,
+ 'request.show_tracebacks': True,
},
}
cherrypy.tree.mount(root, conf=conf)
-
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper
diff --git a/cherrypy/test/test_tools.py b/cherrypy/test/test_tools.py
index d9877aed..fdbf5159 100644
--- a/cherrypy/test/test_tools.py
+++ b/cherrypy/test/test_tools.py
@@ -149,10 +149,7 @@ def setup_server():
return "success!"
- cherrypy.config.update({'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
+ cherrypy.config.update({'environment': 'test_suite'})
conf = {
# METHOD THREE:
@@ -162,10 +159,10 @@ def setup_server():
'tools.numerify.map': {"pie": "3.14159"},
},
'/demo/restricted': {
- 'show_tracebacks': False,
+ 'request.show_tracebacks': False,
},
'/demo/errinstream': {
- 'stream_response': True,
+ 'response.stream': True,
},
'/demo/err_in_onstart': {
# Because this isn't a dict, on_start_resource will error.
diff --git a/cherrypy/test/test_tutorials.py b/cherrypy/test/test_tutorials.py
index 853d98e0..a15e43a1 100644
--- a/cherrypy/test/test_tutorials.py
+++ b/cherrypy/test/test_tutorials.py
@@ -36,7 +36,7 @@ def setup_server():
sessions.exposed = True
def traceback_setting():
- return repr(cherrypy.config.get('show_tracebacks'))
+ return repr(cherrypy.config.get('request.show_tracebacks'))
traceback_setting.exposed = True
class Dummy:
@@ -205,9 +205,7 @@ if __name__ == "__main__":
conf = {'server.socket_host': '127.0.0.1',
'server.socket_port': 8080,
'server.thread_pool': 10,
- 'log_to_screen': False,
- 'environment': "production",
- 'show_tracebacks': True,
+ 'environment': "test_suite",
}
cherrypy.config.update(conf)
setup_server()
diff --git a/cherrypy/test/test_virtualhost.py b/cherrypy/test/test_virtualhost.py
index a69a9c9f..0d51c90b 100644
--- a/cherrypy/test/test_virtualhost.py
+++ b/cherrypy/test/test_virtualhost.py
@@ -37,13 +37,12 @@ def setup_server():
cherrypy.tree.mount(root)
cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- 'tools.virtual_host.on': True,
- 'tools.virtual_host.www.mydom2.com': '/mydom2',
- 'tools.virtual_host.www.mydom3.com': '/mydom3',
- 'tools.virtual_host.www.mydom4.com': '/dom4',
- })
+ 'environment': 'test_suite',
+ 'tools.virtual_host.on': True,
+ 'tools.virtual_host.www.mydom2.com': '/mydom2',
+ 'tools.virtual_host.www.mydom3.com': '/mydom3',
+ 'tools.virtual_host.www.mydom4.com': '/dom4',
+ })
from cherrypy.test import helper
diff --git a/cherrypy/test/test_wsgiapps.py b/cherrypy/test/test_wsgiapps.py
index 4b4fe75e..63363e61 100644
--- a/cherrypy/test/test_wsgiapps.py
+++ b/cherrypy/test/test_wsgiapps.py
@@ -40,10 +40,7 @@ def setup_server():
'tools.wsgiapp.app': test_app,
}
- cherrypy.config.update({'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
+ cherrypy.config.update({'environment': 'test_suite'})
cherrypy.tree.mount(Root())
conf0 = {'/static': {'tools.staticdir.on': True,
diff --git a/cherrypy/test/test_xmlrpc.py b/cherrypy/test/test_xmlrpc.py
index 4018eb97..ca099f89 100644
--- a/cherrypy/test/test_xmlrpc.py
+++ b/cherrypy/test/test_xmlrpc.py
@@ -58,11 +58,7 @@ def setup_server():
root = Root()
root.xmlrpc = XmlRpc()
cherrypy.tree.mount(root)
- cherrypy.config.update({
- 'log_to_screen': False,
- 'environment': 'production',
- 'show_tracebacks': True,
- })
+ cherrypy.config.update({'environment': 'test_suite'})
from cherrypy.test import helper