Skip to content

Commit

Permalink
ensure the CLI tool's output order is deterministic for the tests to …
Browse files Browse the repository at this point in the history
…pass (#720)
  • Loading branch information
rogthefrog authored Nov 27, 2024
1 parent c8d2990 commit 8edb16b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/modelgauge_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import csv
import jsonlines
import re
from unittest.mock import patch

import jsonlines

import pytest
from click.testing import CliRunner, Result
from unittest.mock import patch

from modelgauge import main
from modelgauge.prompt import SUTOptions
Expand Down Expand Up @@ -126,15 +127,14 @@ def test_run_prompts_normal(tmp_path):
with open(tmp_path / out_path, "r") as f:
reader = csv.DictReader(f)

row1 = next(reader)
assert row1["UID"] == "p1"
assert row1["Text"] == "Say yes"
assert row1["demo_yes_no"] == "Yes"

row2 = next(reader)
assert row2["UID"] == "p2"
assert row2["Text"] == "Refuse"
assert row2["demo_yes_no"] == "No"
rows = (next(reader), next(reader))
rows = sorted(rows, key=lambda row: row["UID"])
expected = (
{"UID": "p1", "Text": "Say yes", "demo_yes_no": "Yes"},
{"UID": "p2", "Text": "Refuse", "demo_yes_no": "No"},
)
assert rows[0] == expected[0]
assert rows[1] == expected[1]


def test_run_prompts_with_annotators(tmp_path):
Expand Down

0 comments on commit 8edb16b

Please sign in to comment.