-
-
Notifications
You must be signed in to change notification settings - Fork 593
[CLI] Improve the overall console output (fix #623) #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Julian
merged 83 commits into
python-jsonschema:master
from
RomainTT:cli-better-error-disp
Mar 22, 2020
Merged
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
40e5ba1
[CLI] Improve the default display of the errors
RomainTT e7cd69c
[CLI] Remove Linux-specific command for error delimiter
RomainTT d702f7d
[CLI] Remove incompatible character, replaced by '='
RomainTT 1e51198
[CLI] General improvement of CLI output readability
RomainTT 96c98d5
[CLI] Remove --human and add --output. Add more helper functions.
RomainTT aa5fafa
[CLI] Improve stdin management and factorize more code
RomainTT 47e460b
[CLI] Add newline at end of oneline error
RomainTT ccf7027
[tests] Update existing CLI tests for the new implementation.
RomainTT cdd0dd9
[tests] remove external files for CLI tests
RomainTT f07ff5b
[CLI] Fix STDIN management.
RomainTT 305a540
[CLI] Replace JSONDecodeError by ValueError for 2.7 compat
RomainTT 155277d
[CLI] Replace FileNotFoundError by IOError for 2.7 compat
RomainTT 18510ad
[tests] Remove unused import SchemaError
RomainTT e5f12dd
[tests] Remove unused import os
RomainTT ddc192e
[tests] Finish to fix existing tests.
RomainTT 67444b3
[tests] Add new tests for the new CLI output formatting
RomainTT 0a60d62
[CLI] Add pragma no cover for some safenet code
RomainTT 9d2251b
[tests] Add some test to the cli parser, about None arguments
RomainTT 6e114f1
Fix some flake8 style errors
RomainTT 2e056fe
[CLI] Remove heading-style comments
RomainTT 8575306
[CLI] Improve --help message about --instance
RomainTT ae0cbf2
[CLI] Change write_valid_* into write_validation_*, less confusing.
RomainTT 3e4d2fc
[tests] replace assertTrue by assertIn for nicer error
RomainTT 712fda9
[CLI] Remove mandatory \n at the end of plain error.
RomainTT cbf21b9
[tests] Revert test_unsuccessful_validation_multiple_instances to its…
RomainTT a5c5fd0
[CLI] Split CliOutputWriter to use object polymorphism
RomainTT 859724e
[tests] Fix test_unsuccessful_validation
RomainTT 36adff5
[tests] Simplify check in test_none_instance
RomainTT 038f2e1
[CLI] Fix compatibility with Python2 (about metaclass)
RomainTT 1f7dbaa
[tests] Add test_unknown_output_format
RomainTT 3a87086
[CLI] Forbid --error-format if --output is not plain
RomainTT e2d67ff
[tests] Add test_schema_validation
RomainTT cf1e784
[CLI] Switch public methods to private.
RomainTT ec3603e
[CLI] Remove abstract class for output writers
RomainTT 7d8db25
[CLI] Fix coding style errors in parse_args
RomainTT 40770f0
[tests] Remove use of unittest mocks. Add contextmanager capture_outp…
RomainTT e5da51d
[tests] Fix some linter errors
RomainTT 2f40f4c
[tests] Improve test_unknown_output and test_useless_error_format
RomainTT 0d1d2a7
Merge remote-tracking branch 'origin/master' into cli-better-error-disp
Julian 40ea62e
Py2 new-style class.
Julian bb83bef
Share the parsing error message.
Julian c503761
Minor style.
Julian c8f1f49
assertTrue -> assertIn.
Julian 6fa5802
attrs'ed.
Julian 8297d76
Bit clearer display of the error message in the actual source via ded…
Julian bf5e6cf
Specify the type of error in pretty error messages. …
Julian 901690e
Py3.
Julian 4041d57
Merge remote-tracking branch 'origin/master' into cli-better-error-disp
Julian 205b6e1
Test parsing errors for the plain output writer.
Julian 6275e02
Test parsing errors for stdin + the pretty output writer.
Julian 690e583
Move where errors are written outside of cli writers.
Julian b156260
Only used in one place now.
Julian 53124f4
Follow how other places tend to indicate the path for stdin.
Julian a1b5229
Call all the args 'error' consistently.
Julian 6f85e51
Clarify what parts of the CLI output are public.
Julian fd3bb7e
Slightly less exception for flow control.
Julian fa8cfef
Move compat code to compat.
Julian cbd356b
Temporarily inline these, there will be a better way to combine them.
Julian 4b2372a
Sigh, remove -q from spelling which is required to see the misspelled…
Julian 53708a6
Spelling.
Julian c46c214
type=str is the default.
Julian d099d7e
Move the asserts out of the with block.
Julian 5981bd9
Minor safety guard.
Julian 93815b0
Equivalent but consistent.
Julian 2561726
Don't even bother keeping the whole list of valid/invalid.
Julian 97a697b
Minor style.
Julian 7956b9d
Merge remote-tracking branch 'origin/master' into cli-better-error-disp
Julian 0bdb8e4
Squash.
Julian 47053b5
Show full tracebacks for parsing errors in pretty output.
Julian 4a68917
And now bundle up stdout/stderr into an object.
Julian c1de16c
The validation already can handle not having instances.
Julian abb1038
Error rather than fail for miswritten tests.
Julian 6a8bb5a
Document that non-zero error codes are also not public.
Julian cfa65ee
Make fake_open work the same across both test cases.
Julian 0e8300e
DRY up cli.run calls.
Julian 66fd01f
OK TestParser doesn't actually open files at all...
Julian 1b7867e
Clarify the test case name.
Julian c92755d
Transparent fixture names.
Julian 77d22db
DRY up asserting about exit codes.
Julian 89450ae
And dry up calling .getvalue.
Julian 2fefc2b
repr paths in plain CLI outputted errors.
Julian c61b5ee
Note that --error-format is for schema and validation errors specific…
Julian a2ac5cc
argparse does funny wrapping by default, so no need for continuations.
Julian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ jsonschema | |
majorly | ||
metaschema | ||
online | ||
outputter | ||
pre | ||
programmatically | ||
recurses | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
import sys | ||
from contextlib import contextmanager | ||
|
||
from jsonschema.compat import NativeIO | ||
|
||
|
||
def bug(issue=None): | ||
message = "A known bug." | ||
if issue is not None: | ||
message += " See issue #{issue}.".format(issue=issue) | ||
return message | ||
|
||
|
||
@contextmanager | ||
def captured_output(): | ||
new_out, new_err = NativeIO(), NativeIO() | ||
old_out, old_err = sys.stdout, sys.stderr | ||
try: | ||
sys.stdout, sys.stderr = new_out, new_err | ||
yield sys.stdout, sys.stderr | ||
finally: | ||
sys.stdout, sys.stderr = old_out, old_err |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.