<s> """<STR_LIT>""" <EOL> import nose <EOL> from nose . tools import assert_equal , with_setup <EOL> from unittest . mock import MagicMock , patch <EOL> from prompt_toolkit . interface import CommandLineInterface <EOL> from prompt_toolkit . document import Document <EOL> from prompt_toolkit . buffer import Buffer , AcceptAction <EOL> from xonsh . environ import Env <EOL> from xonsh . tools import ON_WINDOWS <EOL> def setup ( ) : <EOL> global indent_ <EOL> global buffer <EOL> global bufaccept <EOL> global cli <EOL> global carriage_return <EOL> global builtins <EOL> import builtins <EOL> builtins . __xonsh_env__ = Env ( ) <EOL> builtins . __xonsh_env__ [ '<STR_LIT>' ] = '<STR_LIT:U+0020>' <EOL> from xonsh . ptk . key_bindings import carriage_return <EOL> indent_ = '<STR_LIT:U+0020>' <EOL> buffer = Buffer ( ) <EOL> bufaccept = MagicMock ( name = '<STR_LIT>' , spec = AcceptAction ) <EOL> cli = MagicMock ( name = '<STR_LIT>' , spec = CommandLineInterface ) <EOL> buffer . accept_action = bufaccept <EOL> def teardown ( ) : <EOL> global indent_ <EOL> global buffer <EOL> global bufaccept <EOL> global cli <EOL> global carriage_return <EOL> global builtins <EOL> del indent_ <EOL> del buffer <EOL> del bufaccept <EOL> del cli <EOL> del carriage_return <EOL> del builtins <EOL> def test_colon_indent ( ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert_equal ( buffer . document . current_line , indent_ ) <EOL> def test_dedent ( ) : <EOL> document = Document ( '<STR_LIT:\n>' + indent_ + '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert_equal ( buffer . document . current_line , '<STR_LIT>' ) <EOL> document = Document ( '<STR_LIT:\n>' + <NUM_LIT:2> * indent_ + '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert_equal ( buffer . document . current_line , indent_ ) <EOL> def test_nodedent ( ) : <EOL> '''<STR_LIT>''' <EOL> mock = MagicMock ( return_value = True ) <EOL> with patch ( '<STR_LIT>' , mock ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert bufaccept . mock_calls is not None <EOL> mock = MagicMock ( return_value = True ) <EOL> with patch ( '<STR_LIT>' , mock ) : <EOL> document = Document ( indent_ + '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert bufaccept . mock_calls is not None <EOL> def test_continuation_line ( ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert_equal ( buffer . document . current_line , '<STR_LIT>' ) <EOL> def test_trailing_slash ( ) : <EOL> mock = MagicMock ( return_value = True ) <EOL> with patch ( '<STR_LIT>' , mock ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> if not ON_WINDOWS : <EOL> assert_equal ( buffer . document . current_line , '<STR_LIT>' ) <EOL> else : <EOL> assert bufaccept . mock_calls is not None <EOL> def test_cant_compile_newline ( ) : <EOL> mock = MagicMock ( return_value = False ) <EOL> with patch ( '<STR_LIT>' , mock ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert_equal ( buffer . document . current_line , '<STR_LIT>' ) <EOL> def test_can_compile_and_executes ( ) : <EOL> mock = MagicMock ( return_value = True ) <EOL> with patch ( '<STR_LIT>' , mock ) : <EOL> document = Document ( '<STR_LIT>' ) <EOL> buffer . set_document ( document ) <EOL> carriage_return ( buffer , cli ) <EOL> assert bufaccept . mock_calls is not None <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> nose . runmodule ( ) </s>
