def test_nodedent(ctx):
 mock = MagicMock(return_value=True)
 with patch('xonsh.ptk.key_bindings.can_compile', mock):
  document = Document('pass')
  ctx.buffer.set_document(document)
  ctx.cr(ctx.buffer, ctx.cli)
  assert (ctx.accept.mock_calls is not None)
 mock = MagicMock(return_value=True)
 with patch('xonsh.ptk.key_bindings.can_compile', mock):
  document = Document((ctx.indent + 'pass'))
  ctx.buffer.set_document(document)
  ctx.cr(ctx.buffer, ctx.cli)
  assert (ctx.accept.mock_calls is not None)

def test_nodedent ( ctx ) : mock = MagicMock ( return_value = True ) with patch ( 'xonsh.ptk.key_bindings.can_compile' , mock ) : document = Document ( 'pass' ) ctx . buffer . set_document ( document ) ctx . cr ( ctx . buffer , ctx . cli ) assert ( ctx . accept . mock_calls is not None ) mock = MagicMock ( return_value = True ) with patch ( 'xonsh.ptk.key_bindings.can_compile' , mock ) : document = Document ( ( ctx . indent + 'pass' ) ) ctx . buffer . set_document ( document ) ctx . cr ( ctx . buffer , ctx . cli ) assert ( ctx . accept . mock_calls is not None )
dont dedent if first line of ctx .