Skip to content

Commit

Permalink
Fix --set-schema (which was treating cases as dicts).
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Oct 27, 2022
1 parent dbc0483 commit 090f259
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bowtie/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ async def _run(
seq = 0
should_stop = False
for seq, case, case_reporter in sequenced(cases, reporter):
if set_schema and not isinstance(case["schema"], bool):
case["schema"]["$schema"] = dialect
if set_schema and not isinstance(case.schema, bool):
case.schema["$schema"] = dialect

responses = [
each.run_case(seq=seq, case=case) for each in runners
Expand Down
13 changes: 13 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ async def test_it_runs_tests_from_a_file(tmp_path, envsonschema):
assert returncode == 0


@pytest.mark.asyncio
async def test_set_schema_sets_a_dialect_explicitly(envsonschema):
async with bowtie("-i", envsonschema, "--set-schema") as send:
returncode, results, _, _, stderr = await send(
"""
{"description": "a test case", "schema": {}, "tests": [{"description": "valid:1", "instance": {}}] }
""", # noqa: E501
)

assert results == [[{"valid": True}]], stderr
assert returncode == 0


@pytest.mark.asyncio
async def test_no_tests_run(envsonschema):
async with bowtie("-i", envsonschema) as send:
Expand Down

0 comments on commit 090f259

Please sign in to comment.