From f6c3ef7ed3efd6f63ef55a117fe475bd369d248b Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Thu, 5 Apr 2018 17:55:06 +0300 Subject: [PATCH] Tests: added Python test with not iterable object. --- test/python/close/wsgi.py | 1 + test/python/close_error/wsgi.py | 1 + test/python/not_iterable/wsgi.py | 7 +++++++ test/test_python_application.py | 11 +++++++++++ 4 files changed, 20 insertions(+) create mode 100644 test/python/not_iterable/wsgi.py diff --git a/test/python/close/wsgi.py b/test/python/close/wsgi.py index f80a34d7..c86a6097 100644 --- a/test/python/close/wsgi.py +++ b/test/python/close/wsgi.py @@ -5,6 +5,7 @@ class application: def __iter__(self): self.start('200', [(('Content-Length', '0'))]) + yield b'' def close(self): self.environ['wsgi.errors'].write('Close called.') diff --git a/test/python/close_error/wsgi.py b/test/python/close_error/wsgi.py index bd9d4d36..3e9fb63d 100644 --- a/test/python/close_error/wsgi.py +++ b/test/python/close_error/wsgi.py @@ -5,6 +5,7 @@ class application: def __iter__(self): self.start('200', [(('!', '0'))]) + yield b'' def close(self): self.environ['wsgi.errors'].write('Close called.') diff --git a/test/python/not_iterable/wsgi.py b/test/python/not_iterable/wsgi.py new file mode 100644 index 00000000..ad24cca9 --- /dev/null +++ b/test/python/not_iterable/wsgi.py @@ -0,0 +1,7 @@ +class application: + def __init__(self, environ, start_response): + self.environ = environ + self.start = start_response + + def __iter__(self): + self.start('200', [(('Content-Length', '0'))]) diff --git a/test/test_python_application.py b/test/test_python_application.py index 7e1df887..f54d5803 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -227,5 +227,16 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertIsNotNone(self.search_in_log(r'Close called\.'), 'close error') + def test_python_application_not_iterable(self): + self.load('not_iterable') + + self.get(raw_resp=True) + + self.stop() + + self.assertIsNotNone(self.search_in_log( + r'\[error\].+the application returned not an iterable object'), + 'not iterable') + if __name__ == '__main__': unittest.main()