def test_stopped_format_get_current_state(capsys, states, pidfile): if pidfile.is_locked(): pidfile.release() check = '' for state, details in states.items(): warning = 'WARNING: plight is not running\n' message = '{0}State: {1}\nCode: {2}\nMessage: {3}\n' check = message.format( warning, state, details['code'], details['message']) util.format_get_current_state(state, details) out, err = capsys.readouterr() assert out == check
def test_running_format_get_current_state(capsys, states, pidfile): if not pidfile.is_locked(): pidfile.acquire() check = '' for state, details in states.items(): message = 'State: {0}\nCode: {1}\nMessage: {2}\n' check = message.format(state, details['code'], details['message']) util.format_get_current_state(state, details) out, err = capsys.readouterr() assert out == check if pidfile.is_locked(): pidfile.release()