def test_run_working_command_returns_message(): """Check that a single line is returned from command .""" output, error, code = run.run_command('echo "Hello!"') assert error == b"" system_name = platform.system() # running an "echo" will have a trailing newline if system_name is LINUX or system_name is MAC: assert output == b"Hello!\n" # running an "echo" will have a carriage return and then trailing newline elif system_name is WINDOWS: assert output == b'"Hello!"\r\n' assert code == 0
def invoke_all_command_executes_checks(command): """Perform the check for whether or not a command runs without error""" # pylint: disable=unused-variable command_output, command_error, command_returncode = run.run_command(command) # note that a zero-code means that the command did not work # this is the opposite of what is used for processes # but, all other GatorGrader checks return 0 on failure and 1 on success command_passed = False if command_error == EMPTY and command_returncode == SUCCESS: command_passed = True message = "The command '" + str(command) + "'" + " executes correctly" diagnostic = "The command returned the error code " + str(command_returncode) report_result(command_passed, message, diagnostic) return command_passed
def invoke_all_command_executes_checks(command): """Perform the check for whether or not a command runs without error.""" # pylint: disable=unused-variable # note that the program does not use all of these # return values, but we are capturing them if needed for debugging command_output, command_error, command_returncode = run.run_command( command) # note that a zero-code means that the command did not work # this is the opposite of what is used for processes # but, all other GatorGrader checks return 0 on failure and 1 on success command_passed = False if (command_error == constants.markers.Empty and command_returncode == constants.codes.Success): command_passed = True # create the message and diagnostic and report the result message = "The command '" + str(command) + "'" + " executes correctly" diagnostic = "The command returned the error code " + str( command_returncode) report_result(command_passed, message, diagnostic) return command_passed
def test_run_broken_command_returns_nonzero(): """Check that a single line is returned from command .""" output, error, code = run.run_command("willnotwork") assert output == b"" assert error != b"" assert code != 0
def test_run_working_command_returns_message(): """Checks that a single line is returned from command """ output, error, code = run.run_command('echo "Hello!"') assert error == b"" assert output == b"Hello!\n" assert code == 0