diff options
Diffstat (limited to 'wsgitools/adapters.py')
-rw-r--r-- | wsgitools/adapters.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/wsgitools/adapters.py b/wsgitools/adapters.py index 9f2ab1c..f575295 100644 --- a/wsgitools/adapters.py +++ b/wsgitools/adapters.py @@ -12,7 +12,11 @@ class WSGI2to1Adapter: self.app = app def __call__(self, environ, start_response): """WSGI 1.0 interface""" + assert isinstance(environ, dict) status, headers, iterable = self.app(environ) + assert isinstance(status, str) + assert isinstance(headers, list) + assert hasattr(iterable, "__iter__") start_response(status, headers) return iterable @@ -25,14 +29,18 @@ class WSGI1to2Adapter: self.app = app def __call__(self, environ): """some interface that might somewhen be known as WSGI 2.0""" + assert isinstance(environ, dict) results = [None, None, []] def start_response(status, headers, exc_info=None): + assert isinstance(status, str) + assert isinstance(headers, list) results[0] = status results[1] = headers def write_callable(data): results[2].append(data) return write_callable iterable = self.app(environ, start_response) + assert hasattr(iterable, "__iter__") if isinstance(iterable, list): # retaining .close attribute this way iterable[:0] = results[2] |