Skip to content

Commit

Permalink
Shut-up python mode in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Jun 19, 2016
1 parent 88fe424 commit f3c8b22
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/smartparens-commands-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
((eq mode 'elisp) (emacs-lisp-mode))
((eq mode 'racket) (racket-mode))
((eq mode 'c) (c-mode))
((eq mode 'python) (python-mode)))
((eq mode 'python) (shut-up (python-mode))))
(smartparens-mode 1))

;; TODO: don't use this, simply define the tests manually. Gives more
Expand Down
23 changes: 13 additions & 10 deletions test/smartparens-python-test.el
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
(require 'ert)
(require 'smartparens)

(defun sp-test--python-mode ()
(shut-up (python-mode)))

(ert-deftest sp-test-dont-reindent-python ()
(sp-test-with-temp-buffer "if foo:
bar()
baz = biz.boz|"
(python-mode)
(sp-test--python-mode)
(sp-backward-kill-word 1)
(should (equal (buffer-string) "if foo:
bar()
Expand All @@ -14,49 +17,49 @@ baz = biz."))))
(ert-deftest sp-test-python-slurp-whitespace ()
"Ensure we don't add unwanted whitespace when slurping."
(sp-test-with-temp-buffer "foo(|bar)(baz)"
(python-mode)
(sp-test--python-mode)
(sp-forward-slurp-sexp)
(should (equal (buffer-string) "foo(bar(baz))"))))

(ert-deftest sp-test-python-square-bracket-whitespace ()
"Ensure we don't add unwanted whitespace when slurping."
(sp-test-with-temp-buffer "foo[|bar][baz]"
(python-mode)
(sp-test--python-mode)
(sp-forward-slurp-sexp)
(should (equal (buffer-string) "foo[bar[baz]]"))))

(ert-deftest sp-test-python-backspace-in-strict-mode ()
(sp-test-with-temp-buffer "def foo()|:"
(progn (python-mode)
(progn (sp-test--python-mode)
(smartparens-strict-mode +1))
(execute-kbd-macro (kbd "DEL"))
(should (equal (buffer-string) "def foo():"))))

(ert-deftest sp-test-python-apostrophe-in-string ()
"When inserting ' in a string, don't insert a matched '."
(sp-test-with-temp-buffer "\" | \""
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro "'")
(should (equal (buffer-string) "\" ' \""))))

(ert-deftest sp-test-python-apostrophe-in-comment ()
"When inserting ' in a comment, don't insert a matched '."
(sp-test-with-temp-buffer "# |"
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro "'")
(should (equal (buffer-string) "# '"))))

(ert-deftest sp-test-python-apostrophe-in-code ()
"When inserting ' in code, insert a matching '."
(sp-test-with-temp-buffer ""
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro "'")
(should (equal (buffer-string) "''"))))

(ert-deftest sp-test-python-apostrophe-skip-closing-in-code ()
"When inserting ' at the end of '-delimited string, skip it."
(sp-test-with-temp-buffer ""
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro "'foo'")
(should (equal (buffer-string) "'foo'"))
(should (eobp))))
Expand All @@ -66,14 +69,14 @@ baz = biz."))))
Make sure to skip even in inactive sexps."
(sp-test-with-temp-buffer ""
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro "'foo\C-b\C-db'")
(should (equal (buffer-string) "'fob'"))
(should (eobp))))

(ert-deftest sp-test-python-apostrophe-delete-on-backspace-in-comment ()
"When backspacing over ' it should be deleted."
(sp-test-with-temp-buffer "\"foo; it's| a nice word!\""
(python-mode)
(sp-test--python-mode)
(execute-kbd-macro (kbd "<backspace><backspace><backspace><backspace>|"))
(should (equal (buffer-string) "\"foo; | a nice word!\""))))
4 changes: 2 additions & 2 deletions test/smartparens-slurp-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ bar;"

(ert-deftest sp-test-python-slurp-exclude-colon ()
(sp-test-with-temp-buffer "if bar(|)foo:"
(python-mode)
(shut-up (python-mode))
(sp-slurp-hybrid-sexp)
(should (equal (buffer-string) "if bar(foo):"))))

(ert-deftest sp-test-python-slurp-include-dot ()
(sp-test-with-temp-buffer "(|foo).bar"
(python-mode)
(shut-up (python-mode))
(sp-slurp-hybrid-sexp)
(should (equal (buffer-string) "(foo.bar)"))))

Expand Down

0 comments on commit f3c8b22

Please sign in to comment.