Permalink
Browse files

bring back to 100% test coverage

  • Loading branch information...
maluke committed Aug 18, 2011
1 parent 0ff6ba6 commit e9eadf5867c449634684adc8bbc5c01d101fdeed
Showing with 30 additions and 9 deletions.
  1. +8 −0 tests/test_dec.py
  2. +0 −2 tests/test_request.py
  3. +6 −0 tests/test_request_nose.py
  4. +4 −0 tests/test_response.py
  5. +10 −4 tests/test_util.py
  6. +1 −1 webob/dec.py
  7. +1 −2 webob/request.py
View
@@ -262,3 +262,11 @@ class Klass(object):
self.assertEqual(args_rep, 'a=1, b=2, c=3')
args_rep = _format_args(kw=kw, defaults=dict(a=4, b=5))
self.assertEqual(args_rep, 'c=6')
+
+ def test_middleware_direct_call(self):
+ @wsgify.middleware
+ def mw(req, app):
+ return 'foo'
+
+ app = mw(Response())
+ self.assertEqual(app(Request.blank('/')), 'foo')
View
@@ -81,8 +81,6 @@ def test_body_file_setter_w_string(self):
req.body_file.seek(0)
self.assertEqual(req.body_file.read(), '')
-
-
def test_body_file_setter_non_string(self):
BEFORE = self._makeStringIO('before')
AFTER = self._makeStringIO('after')
@@ -76,6 +76,12 @@ def read(self, size=-1):
return self.data
+def test_limite_length_file_repr():
+ req = Request.blank('/', POST='x')
+ req.body_file_raw = 'dummy'
+ req.is_body_seekable = False
+ eq(repr(req.body_file), "<LimitedLengthFile('dummy', maxlen=1)>")
+
def test_request_wrong_clen(is_seekable=False):
tlen = 1<<20
req = Request.blank('/', POST='x'*tlen)
View
@@ -590,6 +590,10 @@ def test_write_unicode():
res.write(u'a')
eq_(res.text, unicode('La Pe\xc3\xb1aa', 'utf-8'))
+def test_write_unicode_no_charset():
+ res = Response(charset=None)
+ assert_raises(TypeError, res.write, u'a')
+
def test_write_text():
res = Response()
res.body = 'abc'
View
@@ -11,7 +11,7 @@ def tearDown(self):
import warnings
warnings.warn = self.oldwarn
del self.warnings
-
+
def _callFUT(self, text, version, stacklevel):
from webob.util import warn_deprecation
return warn_deprecation(text, version, stacklevel)
@@ -31,13 +31,19 @@ def test_not_1_2(self):
self.assertEqual(deprecation_warning['text'], 'text')
self.assertEqual(deprecation_warning['type'], DeprecationWarning)
self.assertEqual(deprecation_warning['stacklevel'], 2)
-
+
def test_is_1_2(self):
self._callFUT('text', '1.2', 1)
self.assertEqual(len(self.warnings), 1)
deprecation_warning = self.warnings[0]
self.assertEqual(deprecation_warning['text'], 'text')
self.assertEqual(deprecation_warning['type'], DeprecationWarning)
self.assertEqual(deprecation_warning['stacklevel'], 2)
-
-
+
+
+ def test_decode_param_names(self):
+ env = Request.blank('?a=b').environ
+ req = Request(env, decode_param_names=False)
+ self.assertEqual(len(self.warnings), 1)
+ deprecation_warning = self.warnings[0]
+ self.assertEqual(deprecation_warning['type'], DeprecationWarning)
View
@@ -159,7 +159,7 @@ def __call__(self, req, *args, **kw):
return resp(environ, start_response)
else:
if self.middleware_wraps:
- args = (self.middleware_wraps,) + args # TODO: coverage
+ args = (self.middleware_wraps,) + args
return self.func(req, *args, **kw)
def get(self, url, **kw):
View
@@ -58,7 +58,7 @@ def __init__(self, environ,
warn_decode_deprecation()
d['decode_param_names'] = decode_param_names
elif not self.decode_param_names:
- warn_decode_deprecation() # TODO: coverage
+ warn_decode_deprecation()
if kw:
cls = self.__class__
if 'method' in kw:
@@ -1264,7 +1264,6 @@ def __init__(self, file, maxlen):
self.maxlen = maxlen
self.remaining = maxlen
- # TODO: coverage
def __repr__(self):
return '<%s(%r, maxlen=%s)>' % (
self.__class__.__name__,

0 comments on commit e9eadf5

Please sign in to comment.