<s> """<STR_LIT>""" <EOL> from httpie . compat import urlopen <EOL> from httpie . output . streams import BINARY_SUPPRESSED_NOTICE <EOL> from utils import TestEnvironment , http <EOL> from fixtures import BIN_FILE_PATH , BIN_FILE_CONTENT , BIN_FILE_PATH_ARG <EOL> class TestBinaryRequestData : <EOL> def test_binary_stdin ( self , httpbin ) : <EOL> with open ( BIN_FILE_PATH , '<STR_LIT:rb>' ) as stdin : <EOL> env = TestEnvironment ( <EOL> stdin = stdin , <EOL> stdin_isatty = False , <EOL> stdout_isatty = False <EOL> ) <EOL> r = http ( '<STR_LIT>' , '<STR_LIT:POST>' , httpbin . url + '<STR_LIT>' , env = env ) <EOL> assert r == BIN_FILE_CONTENT <EOL> def test_binary_file_path ( self , httpbin ) : <EOL> env = TestEnvironment ( stdin_isatty = True , stdout_isatty = False ) <EOL> r = http ( '<STR_LIT>' , '<STR_LIT:POST>' , httpbin . url + '<STR_LIT>' , <EOL> '<STR_LIT:@>' + BIN_FILE_PATH_ARG , env = env , ) <EOL> assert r == BIN_FILE_CONTENT <EOL> def test_binary_file_form ( self , httpbin ) : <EOL> env = TestEnvironment ( stdin_isatty = True , stdout_isatty = False ) <EOL> r = http ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:POST>' , httpbin . url + '<STR_LIT>' , <EOL> '<STR_LIT>' + BIN_FILE_PATH_ARG , env = env ) <EOL> assert bytes ( BIN_FILE_CONTENT ) in bytes ( r ) <EOL> class TestBinaryResponseData : <EOL> url = '<STR_LIT>' <EOL> @ property <EOL> def bindata ( self ) : <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _bindata = urlopen ( self . url ) . read ( ) <EOL> return self . _bindata <EOL> def test_binary_suppresses_when_terminal ( self ) : <EOL> r = http ( '<STR_LIT:GET>' , self . url ) <EOL> assert BINARY_SUPPRESSED_NOTICE . decode ( ) in r <EOL> def test_binary_suppresses_when_not_terminal_but_pretty ( self ) : <EOL> env = TestEnvironment ( stdin_isatty = True , stdout_isatty = False ) <EOL> r = http ( '<STR_LIT>' , '<STR_LIT:GET>' , self . url , <EOL> env = env ) <EOL> assert BINARY_SUPPRESSED_NOTICE . decode ( ) in r <EOL> def test_binary_included_and_correct_when_suitable ( self ) : <EOL> env = TestEnvironment ( stdin_isatty = True , stdout_isatty = False ) <EOL> r = http ( '<STR_LIT:GET>' , self . url , env = env ) <EOL> assert r == self . bindata </s>
