From d8e4390da96d19a322a6fd3512ccac0200f15ddb Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 6 Mar 2013 14:38:01 +0100 Subject: [PATCH 4/4] test_write_abort.py: test returning -1 from write callback --- Makefile | 1 + tests/test_write_abort.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) create mode 100755 tests/test_write_abort.py diff --git a/Makefile b/Makefile index 9b2369d..10b95a7 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ build-7.10.8: test: build $(PYTHON) tests/test_internals.py -q + $(PYTHON) tests/test_write_abort.py -q # (needs GNU binutils) strip: build diff --git a/tests/test_write_abort.py b/tests/test_write_abort.py new file mode 100755 index 0000000..28e7d1f --- /dev/null +++ b/tests/test_write_abort.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +import os.path +import pycurl +import sys + +pycurl.global_init(pycurl.GLOBAL_DEFAULT) + +def write_cb(_): + # this should cause pycurl.WRITEFUNCTION (without any range errors) + return -1 + +# download the script itself through the file:// protocol into write_cb +c = pycurl.Curl() +c.setopt(pycurl.URL, 'file://' + os.path.abspath(sys.argv[0])) +c.setopt(pycurl.WRITEFUNCTION, write_cb) +try: + c.perform() +except pycurl.error, (err, msg): + # we expect pycurl.E_WRITE_ERROR as the response + assert pycurl.E_WRITE_ERROR == err + +# no additional errors should be reported +assert not hasattr(sys, 'last_value') + +c.close() + +pycurl.global_cleanup() -- 1.7.1