<s> import argparse <EOL> import os <EOL> try : <EOL> from unittest import mock <EOL> except ImportError : <EOL> import mock <EOL> from tap . loader import Loader <EOL> from tap . main import build_suite , get_status , main , parse_args <EOL> from tap . tests import TestCase <EOL> class TestMain ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_exits_with_error ( self ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> stream = open ( os . devnull , '<STR_LIT:w>' ) <EOL> status = main ( argv , stream = stream ) <EOL> self . assertEqual ( <NUM_LIT:1> , status ) <EOL> def test_get_successful_status ( self ) : <EOL> result = mock . Mock ( ) <EOL> result . wasSuccessful . return_value = True <EOL> self . assertEqual ( <NUM_LIT:0> , get_status ( result ) ) <EOL> @ mock . patch . object ( Loader , '<STR_LIT>' ) <EOL> def test_build_suite_from_stdin ( self , load_suite_from_stdin ) : <EOL> args = mock . Mock ( ) <EOL> args . files = [ ] <EOL> expected_suite = mock . Mock ( ) <EOL> load_suite_from_stdin . return_value = expected_suite <EOL> suite = build_suite ( args ) <EOL> self . assertEqual ( expected_suite , suite ) <EOL> @ mock . patch . object ( Loader , '<STR_LIT>' ) <EOL> def test_build_suite_from_stdin_dash ( self , load_suite_from_stdin ) : <EOL> argv = [ '<STR_LIT>' , '<STR_LIT:->' ] <EOL> args = parse_args ( argv ) <EOL> expected_suite = mock . Mock ( ) <EOL> load_suite_from_stdin . return_value = expected_suite <EOL> suite = build_suite ( args ) <EOL> self . assertEqual ( expected_suite , suite ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch . object ( argparse . ArgumentParser , '<STR_LIT>' ) <EOL> def test_when_no_pipe_to_stdin ( self , print_help , sys_exit , mock_stdin ) : <EOL> argv = [ '<STR_LIT>' ] <EOL> mock_stdin . isatty = mock . Mock ( return_value = True ) <EOL> parse_args ( argv ) <EOL> self . assertTrue ( print_help . called ) <EOL> self . assertTrue ( sys_exit . called ) </s>
