diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-04-16 22:51:08 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-04-16 22:51:08 -0700 |
commit | 64ba8e99ec1cc82f99fb9ad8ab1da10b25fe6eb1 (patch) | |
tree | 34b23a4547a050e16151379d0bb2ad0f64635b59 | |
parent | 57e1691862722ea54b2ced7998964396691b602f (diff) | |
download | isort-more-tests.tar.gz |
Initial show_diff coveragemore-tests
-rw-r--r-- | isort/api.py | 2 | ||||
-rw-r--r-- | tests/test_api.py | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/isort/api.py b/isort/api.py index 4648d77a..8e3e2018 100644 --- a/isort/api.py +++ b/isort/api.py @@ -486,7 +486,6 @@ def sort_file( disregard_skip=disregard_skip, **config_kwargs, ) - source_file.stream.close() if changed: if show_diff or ask_to_apply: source_file.stream.seek(0) @@ -499,6 +498,7 @@ def sort_file( str(source_file.path) ): return + source_file.stream.close() tmp_file.replace(source_file.path) if not config.quiet: print(f"Fixing {source_file.path}") diff --git a/tests/test_api.py b/tests/test_api.py index 44db6e62..bc0a4ffa 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -15,6 +15,7 @@ def test_sort_file(tmpdir) -> None: imperfect = tmpdir.join(f"test_needs_changes.py") imperfect.write_text("import b\nimport a\n", "utf8") api.sort_file(imperfect, write_to_stdout=True, show_diff=True) + api.sort_file(imperfect, show_diff=True) def test_check_file(tmpdir) -> None: |