Skip to content
Browse files

Fixed most of the warnings in tests.

  • Loading branch information...
1 parent 31e736c commit 83aa6a42ef840d5128ce6e529024e36b45faca25 @defnull defnull committed Jan 13, 2012
Showing with 11 additions and 24 deletions.
  1. +5 −5 test/test_environ.py
  2. +1 −1 test/test_jinja2.py
  3. +1 −1 test/test_mako.py
  4. +0 −2 test/test_outputfilter.py
  5. +1 −1 test/test_securecookies.py
  6. +0 −13 test/test_wsgi.py
  7. +3 −1 test/tools.py
View
10 test/test_environ.py
@@ -510,34 +510,34 @@ def test_delete_cookie(self):
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'])
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'])
View
2 test/test_jinja2.py
@@ -64,7 +64,7 @@ def test():
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
View
2 test/test_mako.py
@@ -49,7 +49,7 @@ def test():
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
View
2 test/test_outputfilter.py
@@ -149,7 +149,6 @@ def test_cookie(self):
""" 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 @@ def test():
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)
View
2 test/test_securecookies.py
@@ -31,7 +31,7 @@ def tear_down(self):
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()
View
13 test/test_wsgi.py
@@ -131,7 +131,6 @@ def test_cookie(self):
""" 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 @@ def test():
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 @@ def test():
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')
View
4 test/tools.py
@@ -8,13 +8,15 @@
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))

0 comments on commit 83aa6a4

Please sign in to comment.
Something went wrong with that request. Please try again.