diff options
| author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-11-28 23:39:11 -0800 |
|---|---|---|
| committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-11-28 23:39:11 -0800 |
| commit | e9b1bd4e126327bc415b26d1308da5a2cdcdf51e (patch) | |
| tree | e870121ca94aeae6461655274de07b6790181fed /tests/unit/test_main.py | |
| parent | 6ed25c68c738405229faf8664c54cd7f020154e9 (diff) | |
| download | isort-e9b1bd4e126327bc415b26d1308da5a2cdcdf51e.tar.gz | |
Implemented #1603: Support for disabling float_to_top from the command line.
Diffstat (limited to 'tests/unit/test_main.py')
| -rw-r--r-- | tests/unit/test_main.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 08f27463..4af4d58c 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -408,6 +408,53 @@ def function(): main.main([str(tmp_file), "--filename", str(tmp_file)], stdin=build_input_content()) +def test_isort_float_to_top_overrides(tmpdir, capsys): + """Tests isorts supports overriding float to top from CLI""" + test_input = """ +import b + + +def function(): + pass + + +import a +""" + config_file = tmpdir.join(".isort.cfg") + config_file.write( + """ +[settings] +float_to_top=True +""" + ) + python_file = tmpdir.join("file.py") + python_file.write(test_input) + + main.main([str(python_file)]) + out, error = capsys.readouterr() + assert not error + assert "Fixing" in out + assert python_file.read_text(encoding="utf8") == ( + """ +import a +import b + + +def function(): + pass +""" + ) + + python_file.write(test_input) + main.main([str(python_file), "--dont-float-to-top"]) + _, error = capsys.readouterr() + assert not error + assert python_file.read_text(encoding="utf8") == test_input + + with pytest.raises(SystemExit): + main.main([str(python_file), "--float-to-top", "--dont-float-to-top"]) + + def test_isort_with_stdin(capsys): # ensures that isort sorts stdin without any flags |
