MCPcopy
hub / github.com/QData/TextAttack / test_command_line_eval

Function test_command_line_eval

tests/test_command_line/test_eval.py:19–43  ·  view source on GitHub ↗

Tests the command-line function, `textattack eval`. Different from other tests, this one compares the sample output file to *stderr* output of the evaluation.

(name, command, sample_output_file)

Source from the content-addressed store, hash-verified

17
18@pytest.mark.parametrize("name, command, sample_output_file", eval_test_params)
19def test_command_line_eval(name, command, sample_output_file):
20 """Tests the command-line function, `textattack eval`.
21
22 Different from other tests, this one compares the sample output file
23 to *stderr* output of the evaluation.
24 """
25 desired_text = open(sample_output_file).read().strip()
26 desired_text_lines = desired_text.split("\n")
27
28 # Run command and validate outputs.
29 result = run_command_and_get_result(command)
30
31 assert result.stdout is not None
32 assert result.stderr is not None
33
34 stdout = result.stdout.decode().strip()
35 print("stdout =>", stdout)
36 stderr = result.stderr.decode().strip()
37 print("stderr =>", stderr)
38
39 print("desired_text =>", desired_text)
40 stderr_lines = stderr.split("\n")
41 assert desired_text_lines <= stderr_lines
42
43 assert result.returncode == 0

Callers

nothing calls this directly

Calls 3

stripMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected