diff options
author | Marcel Hellkamp <marc@gsites.de> | 2012-01-13 18:21:00 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2012-01-13 18:21:00 +0100 |
commit | 83aa6a42ef840d5128ce6e529024e36b45faca25 (patch) | |
tree | 48ec094f2ccde664994c33102f3f15382ccc4e83 | |
parent | 31e736c55f8bffc3c4bd035458e21809f9864920 (diff) | |
download | bottle-83aa6a42ef840d5128ce6e529024e36b45faca25.tar.gz |
Fixed most of the warnings in tests.
-rwxr-xr-x | test/test_environ.py | 10 | ||||
-rw-r--r-- | test/test_jinja2.py | 2 | ||||
-rw-r--r-- | test/test_mako.py | 2 | ||||
-rwxr-xr-x | test/test_outputfilter.py | 2 | ||||
-rw-r--r-- | test/test_securecookies.py | 2 | ||||
-rwxr-xr-x | test/test_wsgi.py | 13 | ||||
-rwxr-xr-x | test/tools.py | 4 |
7 files changed, 11 insertions, 24 deletions
diff --git a/test/test_environ.py b/test/test_environ.py index 232c949..46c1a2c 100755 --- a/test/test_environ.py +++ b/test/test_environ.py @@ -510,20 +510,20 @@ class TestResponse(unittest.TestCase): response = BaseResponse() response.set_cookie('name', 'value') response.delete_cookie('name') - cookies = [value for name, value in response.wsgiheader() + cookies = [value for name, value in response.headerlist if name.title() == 'Set-Cookie'] self.assertTrue('name=;' in cookies[0]) def test_set_header(self): response = BaseResponse() response['x-test'] = 'foo' - headers = [value for name, value in response.wsgiheader() + headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo'], headers) self.assertEqual('foo', response['x-test']) response['X-Test'] = 'bar' - headers = [value for name, value in response.wsgiheader() + headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['bar'], headers) self.assertEqual('bar', response['x-test']) @@ -531,13 +531,13 @@ class TestResponse(unittest.TestCase): def test_append_header(self): response = BaseResponse() response.set_header('x-test', 'foo') - headers = [value for name, value in response.wsgiheader() + headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo'], headers) self.assertEqual('foo', response['x-test']) response.set_header('X-Test', 'bar', True) - headers = [value for name, value in response.wsgiheader() + headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo', 'bar'], headers) self.assertEqual('bar', response['x-test']) diff --git a/test/test_jinja2.py b/test/test_jinja2.py index a62ed1f..0653dfc 100644 --- a/test/test_jinja2.py +++ b/test/test_jinja2.py @@ -64,7 +64,7 @@ class TestJinja2Template(unittest.TestCase): try: import jinja2 except ImportError: - warn("WARNING: No Jinja2 template support. Skipping tests.") + warn("No Jinja2 template support. Skipping tests.") del TestJinja2Template if __name__ == '__main__': #pragma: no cover diff --git a/test/test_mako.py b/test/test_mako.py index 1b1e5b4..cedba78 100644 --- a/test/test_mako.py +++ b/test/test_mako.py @@ -49,7 +49,7 @@ class TestMakoTemplate(unittest.TestCase): try: import mako except ImportError: - warn("WARNING: No Mako template support. Skipping tests.") + warn("No Mako template support. Skipping tests.") del TestMakoTemplate if __name__ == '__main__': #pragma: no cover diff --git a/test/test_outputfilter.py b/test/test_outputfilter.py index 182bd1e..fb282cf 100755 --- a/test/test_outputfilter.py +++ b/test/test_outputfilter.py @@ -149,7 +149,6 @@ class TestOutputFilter(ServerTestBase): """ WSGI: Cookies """ @bottle.route('/cookie') def test(): - bottle.response.COOKIES['a']="a" bottle.response.set_cookie('b', 'b') bottle.response.set_cookie('c', 'c', path='/') return 'hello' @@ -158,7 +157,6 @@ class TestOutputFilter(ServerTestBase): except: c = self.urlopen('/cookie')['header'].get('Set-Cookie', '').split(',') c = [x.strip() for x in c] - self.assertTrue('a=a' in c) self.assertTrue('b=b' in c) self.assertTrue('c=c; Path=/' in c) diff --git a/test/test_securecookies.py b/test/test_securecookies.py index f362129..4305aa7 100644 --- a/test/test_securecookies.py +++ b/test/test_securecookies.py @@ -31,7 +31,7 @@ class TestSecureCookiesInBottle(unittest.TestCase): bottle.app.pop() def get_pairs(self): - for k, v in bottle.response.wsgiheader(): + for k, v in bottle.response.headerlist: if k == 'Set-Cookie': key, value = v.split(';')[0].split('=', 1) yield key.lower().strip(), value.strip() diff --git a/test/test_wsgi.py b/test/test_wsgi.py index d3f8641..ce2612f 100755 --- a/test/test_wsgi.py +++ b/test/test_wsgi.py @@ -131,7 +131,6 @@ class TestWsgi(ServerTestBase): """ WSGI: Cookies """ @bottle.route('/cookie') def test(): - bottle.response.COOKIES['a']="a" bottle.response.set_cookie('b', 'b') bottle.response.set_cookie('c', 'c', path='/') return 'hello' @@ -140,7 +139,6 @@ class TestWsgi(ServerTestBase): except: c = self.urlopen('/cookie')['header'].get('Set-Cookie', '').split(',') c = [x.strip() for x in c] - self.assertTrue('a=a' in c) self.assertTrue('b=b' in c) self.assertTrue('c=c; Path=/' in c) @@ -283,17 +281,6 @@ class TestDecorators(ServerTestBase): self.assertInBody('401: Unauthorized', '/tpl') self.assertStatus(401, '/tpl') - def test_validate(self): - """ WSGI: Test validate-decorator""" - @bottle.route('/:var') - @bottle.route('/') - @bottle.validate(var=int) - def test(var): return 'x' * var - self.assertStatus(403,'/noint') - self.assertStatus(403,'/') - self.assertStatus(200,'/5') - self.assertBody('xxx', '/3') - def test_truncate_body(self): """ WSGI: Some HTTP status codes must not be used with a response-body """ @bottle.route('/test/:code') diff --git a/test/tools.py b/test/tools.py index c276efa..a52566b 100755 --- a/test/tools.py +++ b/test/tools.py @@ -8,13 +8,15 @@ import wsgiref import wsgiref.simple_server import wsgiref.util import wsgiref.validate -from warnings import warn import mimetypes import uuid from bottle import tob, BytesIO +def warn(msg): + sys.stderr.write('WARNING: %s\n' % msg.strip()) + def tobs(data): ''' Transforms bytes or unicode into a byte stream. ''' return BytesIO(tob(data)) |