<s> import unittest <EOL> import uiautomator <EOL> import os <EOL> from mock import patch <EOL> class TestMisc ( unittest . TestCase ) : <EOL> def test_proxy ( self ) : <EOL> self . assertTrue ( '<STR_LIT>' in os . environ ) <EOL> self . assertTrue ( '<STR_LIT:localhost>' in os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_load ( self ) : <EOL> try : <EOL> from imp import reload <EOL> except : <EOL> pass <EOL> reload ( uiautomator ) <EOL> self . assertIsNotNone ( uiautomator . device ) <EOL> self . assertIsNotNone ( uiautomator . rect ) <EOL> self . assertIsNotNone ( uiautomator . point ) <EOL> def test_rect ( self ) : <EOL> import random <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> top , left = random . randint ( <NUM_LIT:0> , <NUM_LIT:100> ) , random . randint ( <NUM_LIT:0> , <NUM_LIT:100> ) <EOL> bottom , right = random . randint ( <NUM_LIT> , <NUM_LIT> ) , random . randint ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( uiautomator . rect ( top , left , bottom , right ) , { "<STR_LIT>" : top , "<STR_LIT:left>" : left , "<STR_LIT>" : bottom , "<STR_LIT:right>" : right } ) <EOL> def test_point ( self ) : <EOL> import random <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> x , y = random . randint ( <NUM_LIT:0> , <NUM_LIT> ) , random . randint ( <NUM_LIT:0> , <NUM_LIT> ) <EOL> self . assertEqual ( uiautomator . point ( x , y ) , { "<STR_LIT:x>" : x , "<STR_LIT:y>" : y } ) <EOL> def test_next_port ( self ) : <EOL> with patch ( '<STR_LIT>' ) as socket : <EOL> socket . return_value . connect_ex . side_effect = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] <EOL> uiautomator . _init_local_port = <NUM_LIT> <EOL> self . assertEqual ( uiautomator . next_local_port ( ) , <NUM_LIT> ) <EOL> with patch ( '<STR_LIT>' ) as socket : <EOL> socket . return_value . connect_ex . return_value = <NUM_LIT:1> <EOL> uiautomator . _init_local_port = <NUM_LIT> <EOL> self . assertEqual ( uiautomator . next_local_port ( ) , <NUM_LIT> ) </s>
