<s> import mock <EOL> import os <EOL> import stat <EOL> import tempfile <EOL> from . import resize_image <EOL> class TestOutputValidation ( ) : <EOL> def test_no_filename ( self ) : <EOL> assert resize_image . validate_output_file ( None ) , '<STR_LIT>' <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_not_writable ( self , mock_access ) : <EOL> mock_access . return_value = False <EOL> with tempfile . NamedTemporaryFile ( '<STR_LIT:r>' ) as f : <EOL> assert not resize_image . validate_output_file ( f . name ) , '<STR_LIT>' <EOL> def test_normal ( self ) : <EOL> with tempfile . NamedTemporaryFile ( '<STR_LIT:r>' ) as f : <EOL> assert resize_image . validate_output_file ( f . name ) , '<STR_LIT>' <EOL> class TestInputValidation ( ) : <EOL> def test_does_not_exist ( self ) : <EOL> assert not resize_image . validate_input_file ( '<STR_LIT>' ) , '<STR_LIT>' <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_unreadable_file ( self , mock_access ) : <EOL> mock_access . return_value = False <EOL> with tempfile . NamedTemporaryFile ( '<STR_LIT:r>' ) as f : <EOL> assert not resize_image . validate_input_file ( f . name ) , '<STR_LIT>' <EOL> class TestRangeValidation ( ) : <EOL> def test_number_none_and_not_allowed ( self ) : <EOL> assert not resize_image . validate_range ( None , allow_none = False ) , '<STR_LIT>' <EOL> def test_number_not_float_compatible ( self ) : <EOL> value = '<STR_LIT:a>' <EOL> assert not resize_image . validate_range ( value ) , '<STR_LIT>' % value <EOL> def test_number_below_min ( self ) : <EOL> assert not resize_image . validate_range ( <NUM_LIT:0> , min_value = <NUM_LIT:1> ) , '<STR_LIT>' <EOL> def test_number_above_max ( self ) : <EOL> assert not resize_image . validate_range ( <NUM_LIT:2> , max_value = <NUM_LIT:1> ) , '<STR_LIT>' <EOL> def test_range ( self ) : <EOL> assert resize_image . validate_range ( <NUM_LIT:5> , min_value = <NUM_LIT:0> , max_value = <NUM_LIT:255> ) , '<STR_LIT>' </s>
