def invoke_all_command_fragment_checks(command, expected_fragment, expected_count, exact=False): """Perform the check for a fragment existence in the output of a command""" command_output = run.specified_command_get_output(command) return invoke_all_fragment_checks(expected_fragment, expected_count, NOTHING, NOTHING, command_output, exact)
def invoke_all_command_count_checks(command, expected_count, exact=False): """Perform the check for number of lines in the output of a command.""" command_output = run.specified_command_get_output(command) return invoke_all_count_checks( expected_count, constants.markers.Nothing, constants.markers.Nothing, command_output, exact, )
def test_run_command_grab_output_as_string_incorrect_command(tmpdir): """Check that invocation of command produces correct captured output.""" tmpdir.mkdir("Hello1") tmpdir.mkdir("Hello2") tmpdir.mkdir("Hello3") assert len(tmpdir.listdir()) == 3 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" # this command will not work correctly because it does not exist # this means that it should not produce any output output = run.specified_command_get_output("gus " + directory) assert output == ""
def test_run_command_grab_output_as_string(tmpdir): """Checks that invocation of command produces correct captured output""" tmpdir.mkdir("Hello1") tmpdir.mkdir("Hello2") tmpdir.mkdir("Hello3") assert len(tmpdir.listdir()) == 3 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" output = run.specified_command_get_output("ls " + directory) assert "Hello1" in output assert "Hello2" in output assert "Hello3" in output
def test_run_command_grab_output_as_string_correct_command(tmpdir): """Check that invocation of command produces correct captured output.""" tmpdir.mkdir("Hello1") tmpdir.mkdir("Hello2") tmpdir.mkdir("Hello3") assert len(tmpdir.listdir()) == 3 directory = tmpdir.dirname + "/" + tmpdir.basename + "/" # note that this test case passes even when run in AppVeyor CI # thus suggesting that the ls command is supported on Windows output = run.specified_command_get_output("ls " + directory) assert "Hello1" in output assert "Hello2" in output assert "Hello3" in output
def invoke_all_command_regex_checks( command, expected_regex, expected_count, exact=False ): """Perform the check for a regex existence in the output of a command.""" # Since the command did not produce any output (i.e., its output is "" or # Nothing), we need to indicate that this was a command error. This will # later signal that, since this command error-ed, the tool should convert # the output to "" (i.e., Nothing) instead of looking for a file in a directory. # The tool needs this conditional logic since the checking of fragments is # overloaded for files in directories and the output of commands. command_output = run.specified_command_get_output(command) if command_output is constants.markers.Nothing: command_output = constants.markers.Command_Error return invoke_all_regex_checks( expected_regex, expected_count, constants.markers.Nothing, constants.markers.Nothing, command_output, exact, )
def invoke_all_command_count_checks(command, expected_count, exact=False): """Perform the check for number of lines in the output of a command""" command_output = run.specified_command_get_output(command) return invoke_all_count_checks(expected_count, NOTHING, NOTHING, command_output, exact)