Skip to content

Commit

Permalink
chore: Do not require --base-url for schemas loaded via a file when…
Browse files Browse the repository at this point in the history
… dry run is enabled
  • Loading branch information
Stranger6667 committed Jan 1, 2021
1 parent 74ddafe commit 079da46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/schemathesis/cli/callbacks.py
Expand Up @@ -22,7 +22,7 @@ def validate_schema(ctx: click.core.Context, param: click.core.Parameter, raw_va
if not netloc:
if "\x00" in raw_value or not utils.file_exists(raw_value):
raise click.UsageError("Invalid SCHEMA, must be a valid URL or file path.")
if "base_url" not in ctx.params:
if "base_url" not in ctx.params and not ctx.params.get("dry_run", False):
raise click.UsageError('Missing argument, "--base-url" is required for SCHEMA specified by file.')
else:
_validate_url(raw_value)
Expand Down
7 changes: 7 additions & 0 deletions test/cli/test_commands.py
Expand Up @@ -1679,3 +1679,10 @@ def test_exit_first(cli, schema_url, openapi_version):
next_line = lines[idx + 1]
assert next_line == ""
assert "FAILURES" in lines[idx + 2]


@pytest.mark.parametrize("openapi_version", (OpenAPIVersion("3.0"),))
def test_base_url_not_required_for_dry_run(testdir, cli, openapi_version, empty_open_api_3_schema):
schema_file = testdir.makefile(".yaml", schema=yaml.dump(empty_open_api_3_schema))
result = cli.run(str(schema_file), "--dry-run")
assert result.exit_code == ExitCode.OK, result.stdout

0 comments on commit 079da46

Please sign in to comment.