summaryrefslogtreecommitdiff
path: root/jsonschema/tests
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2022-11-01 15:40:06 -0400
committerJulian Berman <Julian@GrayVines.com>2022-11-01 15:41:50 -0400
commitf40199de80d3069265da4caf2d3b89a874830dde (patch)
treecc2ba3ab044b69a0925659a16746da70ace33b83 /jsonschema/tests
parent669bd47422089d0405f42c3d32e7abf9a85310bf (diff)
downloadjsonschema-f40199de80d3069265da4caf2d3b89a874830dde.tar.gz
Deprecate the CLI (via import or running normally).
It is less featureful (and less maintained) than the new 'official' option, check-jsonschema. See https://github.com/python-jsonschema/check-jsonschema for details. Closes: #600
Diffstat (limited to 'jsonschema/tests')
-rw-r--r--jsonschema/tests/test_cli.py9
-rw-r--r--jsonschema/tests/test_deprecations.py13
2 files changed, 20 insertions, 2 deletions
diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py
index b4b59f7..9011a76 100644
--- a/jsonschema/tests/test_cli.py
+++ b/jsonschema/tests/test_cli.py
@@ -9,6 +9,7 @@ import os
import subprocess
import sys
import tempfile
+import warnings
try: # pragma: no cover
from importlib import metadata
@@ -17,7 +18,7 @@ except ImportError: # pragma: no cover
from pyrsistent import m
-from jsonschema import Draft4Validator, Draft202012Validator, cli
+from jsonschema import Draft4Validator, Draft202012Validator
from jsonschema.exceptions import (
RefResolutionError,
SchemaError,
@@ -25,6 +26,10 @@ from jsonschema.exceptions import (
)
from jsonschema.validators import _LATEST_VERSION, validate
+with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ from jsonschema import cli
+
def fake_validator(*errors):
errors = list(reversed(errors))
@@ -895,7 +900,7 @@ class TestCLIIntegration(TestCase):
def test_version(self):
version = subprocess.check_output(
- [sys.executable, "-m", "jsonschema", "--version"],
+ [sys.executable, "-W", "ignore", "-m", "jsonschema", "--version"],
stderr=subprocess.STDOUT,
)
version = version.decode("utf-8").strip()
diff --git a/jsonschema/tests/test_deprecations.py b/jsonschema/tests/test_deprecations.py
index 54e2267..54acd86 100644
--- a/jsonschema/tests/test_deprecations.py
+++ b/jsonschema/tests/test_deprecations.py
@@ -1,4 +1,6 @@
from unittest import TestCase
+import subprocess
+import sys
from jsonschema import FormatChecker, validators
@@ -261,3 +263,14 @@ class TestDeprecations(TestCase):
with self.assertRaises(ImportError):
from jsonschema import draft1234_format_checker # noqa
+
+ def test_cli(self):
+ """
+ As of v4.17.0, the jsonschema CLI is deprecated.
+ """
+
+ process = subprocess.run(
+ [sys.executable, "-m", "jsonschema"],
+ capture_output=True,
+ )
+ self.assertIn(b"The jsonschema CLI is deprecated ", process.stderr)