From bec1b6c1b2d23eda302a2bdca40bc65b2564653a Mon Sep 17 00:00:00 2001 From: anirudnits Date: Tue, 22 Sep 2020 00:16:26 +0530 Subject: added test for check-only option with stdin --- tests/unit/test_main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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( -- cgit v1.2.1