@when(u'we send "ctrl + d"')
def step_ctrl_d(context):
 context.cli.sendcontrol(u'd')
 context.exit_sent = True

@ when ( u'we send "ctrl + d"' ) def step_ctrl_d ( context ) : context . cli . sendcontrol ( u'd' ) context . exit_sent = True
send ctrl + d to hopefully exit .