summaryrefslogtreecommitdiff
path: root/lisp/init-python.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-02-10 16:53:29 -0500
committerKyle Meyer <kyle@kyleam.com>2014-02-10 16:53:29 -0500
commit6cbfae79602492590f1078d7530f8ac17c480375 (patch)
tree30c3c5e0a37fee32ed9b019bd7844d5a830d33ad /lisp/init-python.el
parent7c55f78682d68ab00fa66333a5f141f38eadb886 (diff)
downloademacs.d-6cbfae79602492590f1078d7530f8ac17c480375.tar.gz
Make `create-python-test-file` find file if exists
Instead of raising an error if the file exist, just open file in other buffer.
Diffstat (limited to 'lisp/init-python.el')
-rw-r--r--lisp/init-python.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/lisp/init-python.el b/lisp/init-python.el
index 48bbf6d..dce210f 100644
--- a/lisp/init-python.el
+++ b/lisp/init-python.el
@@ -18,12 +18,12 @@ Unless a prefix argument ARG is given, py.test is also imported."
(interactive "P")
(let* ((py-file (file-name-nondirectory buffer-file-name))
(test-file (concat "test_" py-file)))
- (when (file-exists-p test-file)
- (error "Test file %s already exists." test-file))
- (with-current-buffer (find-file-other-window test-file)
- (insert (format "import %s\n" (file-name-sans-extension py-file)))
- (unless arg
- (insert "import pytest\n")))))
+ (find-file-other-window test-file)
+ (unless (file-exists-p test-file)
+ (with-current-buffer
+ (insert (format "import %s\n" (file-name-sans-extension py-file)))
+ (unless arg
+ (insert "import pytest\n"))))))
(defun km/pytest-compile (arg)
"Run pytest.