Skip to content

Commit b936179

Browse files
authored
Resolve conflicts
1 parent ba914b0 commit b936179

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

jsonschema/tests/test_cli.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import subprocess
99
import sys
10+
import tempfile
1011

1112
from jsonschema import Draft4Validator, Draft7Validator, __version__, cli
1213
from jsonschema.exceptions import SchemaError, ValidationError
@@ -683,6 +684,32 @@ def test_successful_validation_of_just_the_schema_pretty_output(self):
683684
stderr="",
684685
)
685686

687+
def test_successful_validation_with_specifying_base_uri(self):
688+
try:
689+
schema_file = tempfile.NamedTemporaryFile(
690+
mode='w+',
691+
prefix='schema',
692+
suffix='.json',
693+
dir='..',
694+
delete=False
695+
)
696+
self.addCleanup(os.remove, schema_file.name)
697+
schema = """
698+
{"type": "object", "properties": {"KEY1":
699+
{"$ref": %s%s#definitions/schemas"}},
700+
"definitions": {"schemas": {"type": "string"}}}
701+
""" % ("\"", os.path.basename(schema_file.name))
702+
schema_file.write(schema)
703+
finally:
704+
schema_file.close()
705+
706+
self.assertOutputs(
707+
files=dict(some_schema=schema, some_instance='{"KEY1": "1"}'),
708+
argv=["-i", "some_instance", "--base-uri", "..", "some_schema"],
709+
stdout="",
710+
stderr="",
711+
)
712+
686713
def test_it_validates_using_the_latest_validator_when_unspecified(self):
687714
# There isn't a better way now I can think of to ensure that the
688715
# latest version was used, given that the call to validator_for
@@ -818,4 +845,4 @@ def test_no_arguments_shows_usage_notes(self):
818845
[sys.executable, "-m", "jsonschema", "--help"],
819846
stderr=subprocess.STDOUT,
820847
)
821-
self.assertEqual(output, output_for_help)
848+
self.assertEqual(output, output_for_help)

0 commit comments

Comments
 (0)