summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2020-01-23 23:39:37 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2020-01-23 23:39:37 -0800
commitfef896afa8a763fdd93bc52e6d47a69f7dda5f9b (patch)
tree31a9875120301512584c200c95fe584e93f8da9e
parent66b5363287a5a071193480278a670df34780d846 (diff)
downloadisort-fef896afa8a763fdd93bc52e6d47a69f7dda5f9b.tar.gz
Add test cases for format module
-rw-r--r--tests/test_format.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_format.py b/tests/test_format.py
new file mode 100644
index 00000000..54028724
--- /dev/null
+++ b/tests/test_format.py
@@ -0,0 +1,18 @@
+from unittest.mock import MagicMock, patch
+
+import pytest
+from hypothesis_auto import auto_pytest_magic
+
+import isort.format
+
+auto_pytest_magic(isort.format.show_unified_diff)
+
+
+def test_ask_whether_to_apply_changes_to_file():
+ with patch("isort.format.input", MagicMock(return_value="y")):
+ assert isort.format.ask_whether_to_apply_changes_to_file("")
+ with patch("isort.format.input", MagicMock(return_value="n")):
+ assert not isort.format.ask_whether_to_apply_changes_to_file("")
+ with patch("isort.format.input", MagicMock(return_value="q")):
+ with pytest.raises(SystemExit):
+ assert isort.format.ask_whether_to_apply_changes_to_file("")