<s> import os . path <EOL> import pycurl <EOL> import sys <EOL> import unittest <EOL> class WriteAbortTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . curl = pycurl . Curl ( ) <EOL> def tearDown ( self ) : <EOL> self . curl . close ( ) <EOL> def write_cb_returning_string ( self , data ) : <EOL> return '<STR_LIT:foo>' <EOL> def write_cb_returning_float ( self , data ) : <EOL> return <NUM_LIT:0.5> <EOL> def test_write_cb_returning_string ( self ) : <EOL> self . check ( self . write_cb_returning_string ) <EOL> def test_write_cb_returning_float ( self ) : <EOL> self . check ( self . write_cb_returning_float ) <EOL> def check ( self , write_cb ) : <EOL> c = pycurl . Curl ( ) <EOL> self . curl . setopt ( pycurl . URL , '<STR_LIT>' + os . path . abspath ( sys . argv [ <NUM_LIT:0> ] ) ) <EOL> self . curl . setopt ( pycurl . WRITEFUNCTION , write_cb ) <EOL> try : <EOL> self . curl . perform ( ) <EOL> except pycurl . error : <EOL> err , msg = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> assert pycurl . E_WRITE_ERROR == err <EOL> assert hasattr ( sys , '<STR_LIT>' ) <EOL> self . assertEqual ( pycurl . error , sys . last_type ) <EOL> assert hasattr ( sys , '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , str ( sys . last_value ) ) </s>
