diff options
author | anirudnits <aniruddha97bhatt@gmail.com> | 2020-09-22 00:16:26 +0530 |
---|---|---|
committer | anirudnits <aniruddha97bhatt@gmail.com> | 2020-09-22 00:16:26 +0530 |
commit | bec1b6c1b2d23eda302a2bdca40bc65b2564653a (patch) | |
tree | f4069086270f5a5e62fbb47a979a8436bceba313 | |
parent | cc34b2c0874094cc419c07d06a2a9cc4bae54255 (diff) | |
download | isort-bec1b6c1b2d23eda302a2bdca40bc65b2564653a.tar.gz |
added test for check-only option with stdin
-rw-r--r-- | tests/unit/test_main.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 82561b38..44e1f7ef 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -203,6 +203,22 @@ import a assert "import a" in out assert "import b" in out + # check should work with stdin + + input_content_check = TextIOWrapper( + BytesIO( + b""" +import b +import a +""" + ) + ) + + with pytest.raises(SystemExit): + main.main(config_args + ["-", "--check-only"], stdin=input_content_check) + out, error = capsys.readouterr() + assert error == "ERROR: Imports are incorrectly sorted and/or formatted.\n" + # Should be able to run with just a file python_file = tmpdir.join("has_imports.py") python_file.write( |