Skip to content

Commit

Permalink
Merge 0982be5 into 19f4fcf
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed May 21, 2020
2 parents 19f4fcf + 0982be5 commit 98f97d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion autopep8.py
Expand Up @@ -4363,7 +4363,12 @@ def main(argv=None, apply_config=True):
assert len(args.files) == 1
assert not args.recursive

ret = fix_multiple_files(args.files, args, sys.stdout)
results = fix_multiple_files(args.files, args, sys.stdout)
if args.diff:
ret = any([len(ret) != 0 for ret in results])
else:
# with in-place option
ret = any([ret is not None for ret in results])
if args.exit_code and ret:
return EXIT_CODE_EXISTS_DIFF
except KeyboardInterrupt:
Expand Down
6 changes: 6 additions & 0 deletions test/test_autopep8.py
Expand Up @@ -5244,6 +5244,12 @@ def test_non_diff_with_exit_code_option(self):
self.assertEqual('', '\n'.join(result.split('\n')[3:]))
self.assertEqual(retcode, autopep8.EXIT_CODE_OK)

def test_non_diff_with_exit_code_and_jobs_options(self):
line = "'abc'\n"
with autopep8_subprocess(line, ['-j0', '--diff', '--exit-code']) as (result, retcode):
self.assertEqual('', '\n'.join(result.split('\n')[3:]))
self.assertEqual(retcode, autopep8.EXIT_CODE_OK)

def test_diff_with_empty_file(self):
with autopep8_subprocess('', ['--diff']) as (result, retcode):
self.assertEqual('\n'.join(result.split('\n')[3:]), '')
Expand Down

0 comments on commit 98f97d5

Please sign in to comment.