Skip to content

Commit 55998e6

Browse files
committed
python-jsonschema#708 - varying length fix
From one version of Python to another, the "type" that appears in brackets may be of differing lengths. (E.g., `JSONDecodeError` in Python 3, but `ValueError` in Python 2.) That would make the length of the Unicode bar different under each version of Python. When these tests were corrected to work under Python 2, they wouldn't work under Python 3 and vice versa. Therefore, it's simpler to break the single assertions into two shorter ones that use very little of the bar characters.
1 parent f584741 commit 55998e6

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

jsonschema/tests/test_cli.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,11 @@ def test_instance_is_invalid_JSON_pretty_output(self):
460460
)
461461
self.assertFalse(stdout)
462462
self.assertIn(
463-
"(some_instance)════════════════════════════════════════╕\nTraceback (most recent call last):\n",
463+
"(some_instance)═",
464+
stderr,
465+
)
466+
self.assertIn(
467+
"═╕\nTraceback (most recent call last):\n",
464468
stderr,
465469
)
466470
self.assertNotIn("some_schema", stderr)
@@ -491,7 +495,11 @@ def test_instance_is_invalid_JSON_on_stdin_pretty_output(self):
491495
)
492496
self.assertFalse(stdout)
493497
self.assertIn(
494-
"(<stdin>)══════════════════════════════════════════════╕\nTraceback (most recent call last):\n",
498+
"(<stdin>)═",
499+
stderr,
500+
)
501+
self.assertIn(
502+
"═╕\nTraceback (most recent call last):\n",
495503
stderr,
496504
)
497505
self.assertNotIn("some_schema", stderr)
@@ -520,7 +528,11 @@ def test_schema_is_invalid_JSON_pretty_output(self):
520528
)
521529
self.assertFalse(stdout)
522530
self.assertIn(
523-
"(some_schema)══════════════════════════════════════════╕\nTraceback (most recent call last):\n",
531+
"(some_schema)═",
532+
stderr,
533+
)
534+
self.assertIn(
535+
"═╕\nTraceback (most recent call last):\n",
524536
stderr,
525537
)
526538

@@ -556,7 +568,11 @@ def test_schema_and_instance_are_both_invalid_JSON_pretty_output(self):
556568
)
557569
self.assertFalse(stdout)
558570
self.assertIn(
559-
"(some_schema)══════════════════════════════════════════╕\nTraceback (most recent call last):\n",
571+
"(some_schema)═",
572+
stderr,
573+
)
574+
self.assertIn(
575+
"═╕\nTraceback (most recent call last):\n",
560576
stderr,
561577
)
562578
self.assertNotIn("some_instance", stderr)

0 commit comments

Comments
 (0)