<s> import py <EOL> from pypy . objspace . std import complexobject as cobj <EOL> from pypy . objspace . std import complextype as cobjtype <EOL> from pypy . objspace . std . objspace import FailedToImplement <EOL> from pypy . objspace . std . stringobject import W_StringObject <EOL> from pypy . objspace . std import StdObjSpace <EOL> EPS = <NUM_LIT> <EOL> class TestW_ComplexObject : <EOL> def _test_instantiation ( self ) : <EOL> def _t_complex ( r = <NUM_LIT:0.0> , i = <NUM_LIT:0.0> ) : <EOL> c = cobj . W_ComplexObject ( r , i ) <EOL> assert c . real == float ( r ) and c . imag == float ( i ) <EOL> pairs = ( <EOL> ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:1.0> , <NUM_LIT> ) , <EOL> ( <NUM_LIT:2> L , <NUM_LIT:3> L ) , <EOL> ) <EOL> for r , i in pairs : <EOL> _t_complex ( r , i ) <EOL> def test_parse_complex ( self ) : <EOL> f = cobjtype . _split_complex <EOL> def test_cparse ( cnum , realnum , imagnum ) : <EOL> result = f ( cnum ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> r , i = result <EOL> assert r == realnum <EOL> assert i == imagnum <EOL> test_cparse ( '<STR_LIT:3>' , '<STR_LIT:3>' , '<STR_LIT>' ) <EOL> test_cparse ( '<STR_LIT>' , '<STR_LIT:3>' , '<STR_LIT:3>' ) <EOL> test_cparse ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> test_cparse ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> test_cparse ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> test_cparse ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_pow ( self ) : <EOL> assert cobj . _pow ( ( <NUM_LIT:0.0> , <NUM_LIT> ) , ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) ) == ( <NUM_LIT:1.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _pow ( ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) , ( <NUM_LIT> , <NUM_LIT:0.0> ) ) == ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> rr , ir = cobj . _pow ( ( <NUM_LIT:0.0> , <NUM_LIT:1.0> ) , ( <NUM_LIT> , <NUM_LIT:0.0> ) ) <EOL> assert abs ( - <NUM_LIT:1.0> - rr ) < EPS <EOL> assert abs ( <NUM_LIT:0.0> - ir ) < EPS <EOL> assert cobj . _powu ( ( <NUM_LIT:0.0> , <NUM_LIT> ) , <NUM_LIT:0> ) == ( <NUM_LIT:1.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _powu ( ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) , <NUM_LIT:2> ) == ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _powu ( ( <NUM_LIT:0.0> , <NUM_LIT:1.0> ) , <NUM_LIT:2> ) == ( - <NUM_LIT:1.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _powi ( ( <NUM_LIT:0.0> , <NUM_LIT> ) , <NUM_LIT:0> ) == ( <NUM_LIT:1.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _powi ( ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) , <NUM_LIT:2> ) == ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert cobj . _powi ( ( <NUM_LIT:0.0> , <NUM_LIT:1.0> ) , <NUM_LIT:2> ) == ( - <NUM_LIT:1.0> , <NUM_LIT:0.0> ) <EOL> c = cobj . W_ComplexObject ( <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> p = cobj . W_ComplexObject ( <NUM_LIT> , <NUM_LIT:0.0> ) <EOL> r = cobj . pow__Complex_Complex_ANY ( self . space , c , p , self . space . wrap ( None ) ) <EOL> assert r . realval == - <NUM_LIT:1.0> <EOL> assert r . imagval == <NUM_LIT:0.0> <EOL> class AppTestAppComplexTest : <EOL> def setup_class ( cls ) : <EOL> cls . w_helper = cls . space . appexec ( [ ] , """<STR_LIT>""" % ( str ( py . magic . autopath ( ) . dirpath ( ) ) ) ) <EOL> def test_div ( self ) : <EOL> h = self . helper <EOL> from random import random <EOL> simple_real = [ - <NUM_LIT> , <NUM_LIT:0.0> , <NUM_LIT:1.0> ] <EOL> simple_complex = [ complex ( x , y ) for x in simple_real for y in simple_real ] <EOL> for x in simple_complex : <EOL> for y in simple_complex : <EOL> h . check_div ( x , y ) <EOL> h . check_div ( complex ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . check_div ( complex ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> for i in xrange ( <NUM_LIT:100> ) : <EOL> h . check_div ( complex ( random ( ) , random ( ) ) , <EOL> complex ( random ( ) , random ( ) ) ) <EOL> h . raises ( ZeroDivisionError , complex . __div__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:0> + <NUM_LIT> ) <EOL> def test_truediv ( self ) : <EOL> h = self . helper <EOL> h . assertAlmostEqual ( complex . __truediv__ ( <NUM_LIT:2> + <NUM_LIT> , <NUM_LIT:1> + <NUM_LIT> ) , <NUM_LIT:1> - <NUM_LIT> ) <EOL> raises ( ZeroDivisionError , complex . __truediv__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:0> + <NUM_LIT> ) <EOL> def test_floordiv ( self ) : <EOL> h = self . helper <EOL> h . assertAlmostEqual ( complex . __floordiv__ ( <NUM_LIT:3> + <NUM_LIT> , <NUM_LIT> + <NUM_LIT> ) , <NUM_LIT:2> ) <EOL> raises ( ZeroDivisionError , complex . __floordiv__ , <NUM_LIT:3> + <NUM_LIT> , <NUM_LIT:0> + <NUM_LIT> ) <EOL> def test_coerce ( self ) : <EOL> h = self . helper <EOL> h . raises ( OverflowError , complex . __coerce__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> L << <NUM_LIT> ) <EOL> def test_richcompare ( self ) : <EOL> h = self . helper <EOL> h . raises ( OverflowError , complex . __eq__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> L << <NUM_LIT> ) <EOL> h . assertEqual ( complex . __lt__ ( <NUM_LIT:1> + <NUM_LIT> , None ) , NotImplemented ) <EOL> h . assertIs ( complex . __eq__ ( <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> + <NUM_LIT> ) , True ) <EOL> h . assertIs ( complex . __eq__ ( <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) , False ) <EOL> h . assertIs ( complex . __ne__ ( <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> + <NUM_LIT> ) , False ) <EOL> h . assertIs ( complex . __ne__ ( <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) , True ) <EOL> h . raises ( TypeError , complex . __lt__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) <EOL> h . raises ( TypeError , complex . __le__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) <EOL> h . raises ( TypeError , complex . __gt__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) <EOL> h . raises ( TypeError , complex . __ge__ , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) <EOL> def test_mod ( self ) : <EOL> h = self . helper <EOL> raises ( ZeroDivisionError , ( <NUM_LIT:1> + <NUM_LIT> ) . __mod__ , <NUM_LIT:0> + <NUM_LIT> ) <EOL> a = <NUM_LIT> + <NUM_LIT> <EOL> try : <EOL> a % <NUM_LIT:0> <EOL> except ZeroDivisionError : <EOL> pass <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_divmod ( self ) : <EOL> h = self . helper <EOL> raises ( ZeroDivisionError , divmod , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:0> + <NUM_LIT> ) <EOL> def test_pow ( self ) : <EOL> h = self . helper <EOL> h . assertAlmostEqual ( pow ( <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:0> + <NUM_LIT> ) , <NUM_LIT:1.0> ) <EOL> h . assertAlmostEqual ( pow ( <NUM_LIT:0> + <NUM_LIT> , <NUM_LIT:2> + <NUM_LIT> ) , <NUM_LIT:0.0> ) <EOL> raises ( ZeroDivisionError , pow , <NUM_LIT:0> + <NUM_LIT> , <NUM_LIT> ) <EOL> h . assertAlmostEqual ( pow ( <NUM_LIT> , - <NUM_LIT:1> ) , <NUM_LIT:1> / <NUM_LIT> ) <EOL> h . assertAlmostEqual ( pow ( <NUM_LIT> , <NUM_LIT:200> ) , <NUM_LIT:1> ) <EOL> raises ( ValueError , pow , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> + <NUM_LIT> , <NUM_LIT:1> + <NUM_LIT> ) <EOL> a = <NUM_LIT> + <NUM_LIT> <EOL> h . assertEqual ( a ** <NUM_LIT> , <NUM_LIT:1> ) <EOL> h . assertEqual ( a ** <NUM_LIT:0.> + <NUM_LIT> , <NUM_LIT:1> ) <EOL> h . assertEqual ( <NUM_LIT> ** <NUM_LIT> , <NUM_LIT:1> ) <EOL> h . assertEqual ( <NUM_LIT> ** <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> try : <EOL> <NUM_LIT> ** a <EOL> except ZeroDivisionError : <EOL> pass <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> try : <EOL> <NUM_LIT> ** ( <NUM_LIT:3> - <NUM_LIT> ) <EOL> except ZeroDivisionError : <EOL> pass <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> h . assertEqual ( a ** <NUM_LIT> , a ** <NUM_LIT> ) <EOL> h . assertEqual ( a ** - <NUM_LIT> , a ** - <NUM_LIT> ) <EOL> h . assertEqual ( a ** - <NUM_LIT:30> , a ** - <NUM_LIT:30> ) <EOL> h . assertEqual ( <NUM_LIT> ** <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> b = <NUM_LIT> + <NUM_LIT> <EOL> h . raises ( ValueError , pow , a , b , <NUM_LIT:0> ) <EOL> def test_boolcontext ( self ) : <EOL> from random import random <EOL> h = self . helper <EOL> for i in xrange ( <NUM_LIT:100> ) : <EOL> assert complex ( random ( ) + <NUM_LIT> , random ( ) + <NUM_LIT> ) <EOL> assert not complex ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> def test_conjugate ( self ) : <EOL> h = self . helper <EOL> h . assertClose ( complex ( <NUM_LIT> , <NUM_LIT> ) . conjugate ( ) , <NUM_LIT> - <NUM_LIT> ) <EOL> def test_constructor ( self ) : <EOL> h = self . helper <EOL> class OS : <EOL> def __init__ ( self , value ) : self . value = value <EOL> def __complex__ ( self ) : return self . value <EOL> class NS ( object ) : <EOL> def __init__ ( self , value ) : self . value = value <EOL> def __complex__ ( self ) : return self . value <EOL> h . assertEqual ( complex ( OS ( <NUM_LIT:1> + <NUM_LIT> ) ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertEqual ( complex ( NS ( <NUM_LIT:1> + <NUM_LIT> ) ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . raises ( TypeError , complex , OS ( None ) ) <EOL> h . raises ( TypeError , complex , NS ( None ) ) <EOL> h . assertAlmostEqual ( complex ( "<STR_LIT>" ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:10> ) , <NUM_LIT:10> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> ) , <NUM_LIT:10> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:10> L ) , <NUM_LIT:10> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:10> + <NUM_LIT> ) , <NUM_LIT:10> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> , <NUM_LIT:10> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> , <NUM_LIT:10> L ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> , <NUM_LIT> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> L , <NUM_LIT:10> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> L , <NUM_LIT:10> L ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1> L , <NUM_LIT> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1.0> , <NUM_LIT:10> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1.0> , <NUM_LIT:10> L ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:1.0> , <NUM_LIT> ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> + <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> L ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> + <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> , <NUM_LIT:0.0> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> , <NUM_LIT:0> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> L , <NUM_LIT:0> L ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> , <NUM_LIT> ) , - <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:0.0> , <NUM_LIT> ) , - <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( <NUM_LIT:0.0> , <NUM_LIT> ) , <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( "<STR_LIT:1>" ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( "<STR_LIT>" ) , <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( ) , <NUM_LIT:0> ) <EOL> h . assertAlmostEqual ( complex ( "<STR_LIT>" ) , - <NUM_LIT:1> ) <EOL> h . assertAlmostEqual ( complex ( "<STR_LIT>" ) , + <NUM_LIT:1> ) <EOL> class complex2 ( complex ) : pass <EOL> h . assertAlmostEqual ( complex ( complex2 ( <NUM_LIT:1> + <NUM_LIT> ) ) , <NUM_LIT:1> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( real = <NUM_LIT> , imag = <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( real = <NUM_LIT> + <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( real = <NUM_LIT> + <NUM_LIT> , imag = <NUM_LIT> ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( real = <NUM_LIT:1> + <NUM_LIT> , imag = <NUM_LIT:3> + <NUM_LIT> ) , - <NUM_LIT:3> + <NUM_LIT> ) <EOL> c = <NUM_LIT> + <NUM_LIT> <EOL> assert complex ( c ) is c <EOL> del c <EOL> h . raises ( TypeError , complex , "<STR_LIT:1>" , "<STR_LIT:1>" ) <EOL> h . raises ( TypeError , complex , <NUM_LIT:1> , "<STR_LIT:1>" ) <EOL> h . assertEqual ( complex ( "<STR_LIT>" ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . raises ( ValueError , complex , '<STR_LIT>' ) <EOL> h . raises ( TypeError , int , <NUM_LIT:5> + <NUM_LIT> ) <EOL> h . raises ( TypeError , long , <NUM_LIT:5> + <NUM_LIT> ) <EOL> h . raises ( TypeError , float , <NUM_LIT:5> + <NUM_LIT> ) <EOL> h . raises ( ValueError , complex , "<STR_LIT>" ) <EOL> h . raises ( TypeError , complex , None ) <EOL> h . raises ( ValueError , complex , "<STR_LIT>" ) <EOL> h . raises ( TypeError , complex , "<STR_LIT:1>" , "<STR_LIT:2>" ) <EOL> h . raises ( TypeError , complex , "<STR_LIT:1>" , <NUM_LIT> ) <EOL> h . raises ( TypeError , complex , <NUM_LIT:1> , "<STR_LIT:2>" ) <EOL> h . raises ( ValueError , complex , "<STR_LIT>" ) <EOL> h . raises ( ValueError , complex , "<STR_LIT>" ) <EOL> h . raises ( ValueError , complex , "<STR_LIT>" ) <EOL> class EvilExc ( Exception ) : <EOL> pass <EOL> class evilcomplex : <EOL> def __complex__ ( self ) : <EOL> raise EvilExc <EOL> h . raises ( EvilExc , complex , evilcomplex ( ) ) <EOL> class float2 : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __float__ ( self ) : <EOL> return self . value <EOL> h . assertAlmostEqual ( complex ( float2 ( <NUM_LIT> ) ) , <NUM_LIT> ) <EOL> h . assertAlmostEqual ( complex ( real = float2 ( <NUM_LIT> ) , imag = float2 ( <NUM_LIT> ) ) , <NUM_LIT> + <NUM_LIT> ) <EOL> h . raises ( TypeError , complex , float2 ( None ) ) <EOL> def test_hash ( self ) : <EOL> h = self . helper <EOL> for x in xrange ( - <NUM_LIT:30> , <NUM_LIT:30> ) : <EOL> h . assertEqual ( hash ( x ) , hash ( complex ( x , <NUM_LIT:0> ) ) ) <EOL> x /= <NUM_LIT> <EOL> h . assertEqual ( hash ( x ) , hash ( complex ( x , <NUM_LIT:0.> ) ) ) <EOL> def test_abs ( self ) : <EOL> h = self . helper <EOL> nums = [ complex ( x / <NUM_LIT> , y / <NUM_LIT> ) for x in xrange ( - <NUM_LIT:9> , <NUM_LIT:9> ) for y in xrange ( - <NUM_LIT:9> , <NUM_LIT:9> ) ] <EOL> for num in nums : <EOL> h . assertAlmostEqual ( ( num . real ** <NUM_LIT:2> + num . imag ** <NUM_LIT:2> ) ** <NUM_LIT:0.5> , abs ( num ) ) <EOL> def test_complex_subclass_ctr ( self ) : <EOL> import sys <EOL> class j ( complex ) : <EOL> pass <EOL> assert j ( <NUM_LIT:100> + <NUM_LIT> ) == <NUM_LIT:100> + <NUM_LIT> <EOL> assert isinstance ( j ( <NUM_LIT:100> ) , j ) <EOL> assert j ( <NUM_LIT:100> L + <NUM_LIT> ) == <NUM_LIT:100> + <NUM_LIT> <EOL> assert j ( "<STR_LIT>" ) == <NUM_LIT:100> + <NUM_LIT> <EOL> x = j ( <NUM_LIT:1> + <NUM_LIT> ) <EOL> x . foo = <NUM_LIT> <EOL> assert x . foo == <NUM_LIT> <EOL> assert type ( complex ( x ) ) == complex <EOL> def test_overflow ( self ) : <EOL> h = self . helper <EOL> raises ( ValueError , complex , unicode ( "<STR_LIT:1>" * <NUM_LIT> ) ) <EOL> def test_repr ( self ) : <EOL> h = self . helper <EOL> h . assertEqual ( repr ( <NUM_LIT:1> + <NUM_LIT> ) , '<STR_LIT>' ) <EOL> h . assertEqual ( repr ( <NUM_LIT:1> - <NUM_LIT> ) , '<STR_LIT>' ) <EOL> h . assertNotEqual ( repr ( - ( <NUM_LIT:1> + <NUM_LIT> ) ) , '<STR_LIT>' ) <EOL> def test_neg ( self ) : <EOL> h = self . helper <EOL> h . assertEqual ( - ( <NUM_LIT:1> + <NUM_LIT> ) , - <NUM_LIT:1> - <NUM_LIT> ) <EOL> def test_file ( self ) : <EOL> h = self . helper <EOL> import os <EOL> import tempfile <EOL> a = <NUM_LIT> + <NUM_LIT> <EOL> b = <NUM_LIT> + <NUM_LIT> <EOL> fo = None <EOL> try : <EOL> pth = tempfile . mktemp ( ) <EOL> fo = open ( pth , "<STR_LIT:wb>" ) <EOL> print >> fo , a , b <EOL> fo . close ( ) <EOL> fo = open ( pth , "<STR_LIT:rb>" ) <EOL> h . assertEqual ( fo . read ( ) , "<STR_LIT>" % ( a , b ) ) <EOL> finally : <EOL> if ( fo is not None ) and ( not fo . closed ) : <EOL> fo . close ( ) <EOL> try : <EOL> os . remove ( pth ) <EOL> except ( OSError , IOError ) : <EOL> pass <EOL> def test_convert ( self ) : <EOL> raises ( TypeError , int , <NUM_LIT:1> + <NUM_LIT> ) <EOL> raises ( TypeError , float , <NUM_LIT:1> + <NUM_LIT> ) </s>
