diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-08 10:05:17 -0800 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-08 10:05:17 -0800 |
commit | 545f652d8a00ea4545351aa60d42fbc8c1270f48 (patch) | |
tree | 3f7e69a192c1d75dd354792dfa5e88350fc3d40a /tests/test_wsgilib.py | |
parent | 3ec0b57275bdbf611f97d959540db0bef9e6edb2 (diff) | |
parent | 6c0792ca62742e5a3cefcbc5d0cba3a4dddf5169 (diff) | |
download | paste-git-545f652d8a00ea4545351aa60d42fbc8c1270f48.tar.gz |
Merged in msabramo/paste/python3_wsgilib_add_close_next (pull request #29)
paste.wsgilib.add_close: Add __next__ method
Diffstat (limited to 'tests/test_wsgilib.py')
-rw-r--r-- | tests/test_wsgilib.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_wsgilib.py b/tests/test_wsgilib.py new file mode 100644 index 0000000..72573cf --- /dev/null +++ b/tests/test_wsgilib.py @@ -0,0 +1,52 @@ +from paste.wsgilib import add_close + + +def app_iterable_func_bytes(): + yield b'a' + yield b'b' + yield b'c' + + +def app_iterable_func_unicode(): + yield b'a'.decode('ascii') + yield b'b'.decode('ascii') + yield b'c'.decode('ascii') + + +def close_func(): + global close_func_called + close_func_called = True + + +def test_add_close_bytes(): + global close_func_called + + close_func_called = False + lst = [] + app_iterable = app_iterable_func_bytes() + + obj = add_close(app_iterable, close_func) + for x in obj: + lst.append(x) + obj.close() + + assert lst == [b'a', b'b', b'c'] + assert close_func_called + assert obj._closed + + +def test_add_close_unicode(): + global close_func_called + + close_func_called = False + lst = [] + app_iterable = app_iterable_func_unicode() + + obj = add_close(app_iterable, close_func) + for x in obj: + lst.append(x) + obj.close() + + assert lst == ['a', 'b', 'c'] + assert close_func_called + assert obj._closed |