<s> import py <EOL> def setup_module ( mod ) : <EOL> try : <EOL> import termios <EOL> mod . termios = termios <EOL> except ImportError : <EOL> py . test . skip ( "<STR_LIT>" ) <EOL> class ExpectTestLLTermios ( object ) : <EOL> def test_tcgetattr ( self ) : <EOL> from pypy . translator . c . test . test_genc import compile <EOL> import termios <EOL> from pypy . rlib import rtermios <EOL> def runs_tcgetattr ( ) : <EOL> tpl = list ( rtermios . tcgetattr ( <NUM_LIT:2> ) [ : - <NUM_LIT:1> ] ) <EOL> return str ( tpl ) <EOL> fn = compile ( runs_tcgetattr , [ ] , backendopt = False ) <EOL> res = fn ( ) <EOL> res2 = str ( rtermios . tcgetattr ( <NUM_LIT:2> ) [ : - <NUM_LIT:1> ] ) <EOL> assert res [ <NUM_LIT:1> : - <NUM_LIT:1> ] == res2 [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> def test_tcgetattr2 ( self ) : <EOL> from pypy . translator . c . test . test_genc import compile <EOL> from pypy . rpython . module import ll_termios <EOL> from pypy . rlib import rtermios <EOL> import termios <EOL> def runs_tcgetattr ( ) : <EOL> try : <EOL> rtermios . tcgetattr ( <NUM_LIT> ) <EOL> except termios . error , e : <EOL> return <NUM_LIT:2> <EOL> return <NUM_LIT:3> <EOL> fn = compile ( runs_tcgetattr , [ ] , backendopt = False ) <EOL> res = fn ( ) <EOL> assert res == <NUM_LIT:2> <EOL> def test_tcsetattr ( self ) : <EOL> from pypy . translator . c . test . test_genc import compile <EOL> from pypy . rpython . module import ll_termios <EOL> from pypy . rlib import rtermios <EOL> import termios , time <EOL> def runs_tcsetattr ( ) : <EOL> tp = rtermios . tcgetattr ( <NUM_LIT:2> ) <EOL> a , b , c , d , e , f , g = tp <EOL> rtermios . tcsetattr ( <NUM_LIT:2> , rtermios . TCSANOW , ( a , b , c , d , e , f , g ) ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> tp = rtermios . tcgetattr ( <NUM_LIT:2> ) <EOL> assert tp [ <NUM_LIT:5> ] == f <EOL> fn = compile ( runs_tcsetattr , [ ] , backendopt = False ) <EOL> fn ( ) <EOL> def test_tcrest ( self ) : <EOL> from pypy . translator . c . test . test_genc import compile <EOL> from pypy . rpython . module import ll_termios <EOL> import termios , time <EOL> def runs_tcall ( ) : <EOL> termios . tcsendbreak ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> termios . tcdrain ( <NUM_LIT:2> ) <EOL> termios . tcflush ( <NUM_LIT:2> , termios . TCIOFLUSH ) <EOL> termios . tcflow ( <NUM_LIT:2> , termios . TCOON ) <EOL> fn = compile ( runs_tcall , [ ] , backendopt = False ) <EOL> fn ( ) <EOL> def test_tcsetattr_icanon ( self ) : <EOL> from pypy . rlib import rtermios <EOL> import termios <EOL> def check ( fd , when , attributes ) : <EOL> count = len ( [ i for i in attributes [ - <NUM_LIT:1> ] if isinstance ( i , int ) ] ) <EOL> assert count == <NUM_LIT:2> <EOL> termios . tcsetattr = check <EOL> attr = list ( rtermios . tcgetattr ( <NUM_LIT:2> ) ) <EOL> attr [ <NUM_LIT:3> ] |= termios . ICANON <EOL> rtermios . tcsetattr ( <NUM_LIT:2> , termios . TCSANOW , attr ) </s>
