1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
;;; py-shell-completion-tests.el --- Test completion for available Python shell
;; Author: Andreas Roehler <andreas.roehler@online.de>
;; Keywords: languages, convenience
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary: Edit `py-test-pyshellname-list' before
;; running this test-builder or give a list of shells as
;; arguments
;;; Code:
(setq python-mode-shell-complete-tests
(list
'python-shell-complete-test
'usr-bin-python-shell-complete-test
'usr-bin-python2.7-shell-complete-test
;; 'arbeit-python-epdfree-epd_free-7.2-2-rh5-x86-bin-python2.7-shell-complete-test
'usr-bin-python3-shell-complete-test
;; 'usr-bin-python3.2-shell-complete-test
;; 'ipython-shell-complete-test
;; 'usr-bin-ipython-shell-complete-test
;; 'arbeit-python-epd_free-7.1-2-rh5-x86-bin-ipython-shell-complete-test
)
)
(defun py-run-shell-complete-tests ()
(interactive)
(dolist (ele python-mode-shell-complete-tests)
(funcall ele)
;; (sit-for 1)
))
(defun python-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
;; (set-buffer (py-shell nil t "python" nil "/"))
(set-buffer (py-shell nil t "python"))
(when (interactive-p) (switch-to-buffer (current-buffer)))
(sit-for 0.2 t)
(goto-char (point-max))
(save-excursion
(insert "pri")
(py-shell-complete))
(sit-for 0.5)
(assert (looking-at "print") nil "python-shell-complete-test failed")
(message "%s" "python-shell-complete-test passed")))
(defun usr-bin-python-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "/usr/bin/python" nil "/"))
(switch-to-buffer (current-buffer))
(sit-for 0.1)
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(forward-word -1)
(sit-for 0.1)
(assert (looking-at "print") nil "usr-bin-python-shell-complete-test failed")
(when py-verbose-p (message "%s" "usr-bin-python-shell-complete-test passed"))))
(defun usr-bin-python2.7-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "/usr/bin/python2.7" nil "/"))
(when (interactive-p) (switch-to-buffer (current-buffer)))
(sit-for 0.1)
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(forward-word -1)
(assert (looking-at "print") nil "usr-bin-python2.7-shell-complete-test failed")
(message "%s" "usr-bin-python2.7-shell-complete-test passed")))
(defun arbeit-python-epdfree-epd_free-7.2-2-rh5-x86-bin-python2.7-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "~/arbeit/python/epdfree/epd_free-7.2-2-rh5-x86/bin/python2.7" nil "/"))
(sit-for 0.2 t)
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(sit-for 0.1)
(forward-word -1)
(assert (looking-at "print") nil "arbeit-python-epdfree-epd_free-7.2-2-rh5-x86-bin-python2.7-shell-complete-test failed")
(when py-verbose-p (message "%s" "arbeit-python-epdfree-epd_free-7.2-2-rh5-x86-bin-python2.7-shell-complete-test passed"))))
(defun usr-bin-python3-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "/usr/local/bin/python3" nil "/"))
(when (interactive-p) (switch-to-buffer (current-buffer)))
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(forward-word -1)
(sit-for 0.1)
(assert (looking-at "print") nil "usr-bin-python3-shell-complete-test failed")
(message "%s" "usr-bin-python3-shell-complete-test passed")))
(defun ipython-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "ipython"))
(switch-to-buffer (current-buffer))
(sit-for 2)
(goto-char (point-max))
;; (comint-send-input)
(insert "pri")
(py-shell-complete)
(sit-for 0.1)
(assert (looking-back "print") nil "ipython-shell-complete-test failed")
(message "%s" "ipython-shell-complete-test passed")))
(defun usr-bin-ipython-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "/usr/bin/ipython" nil "/"))
(sit-for 0.1)
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(sit-for 1 t)
(forward-word -1)
(assert (looking-at "print") nil "usr-bin-ipython-shell-complete-test failed")
(message "%s" "usr-bin-ipython-shell-complete-test passed")))
(defun arbeit-python-epd_free-7.1-2-rh5-x86-bin-ipython-shell-complete-test ()
(interactive)
(let (py-shell-switch-buffers-on-execute-p
py-split-windows-on-execute-p)
(set-buffer (py-shell nil t "~/arbeit/python/epd_free-7.1-2-rh5-x86/bin/ipython" nil "/"))
(sit-for 0.1)
(switch-to-buffer (current-buffer))
(goto-char (point-max))
(insert "pri")
(py-shell-complete)
(sit-for 1 t)
(forward-word -1)
(assert (looking-at "print") nil "arbeit-python-epd_free-7.1-2-rh5-x86-bin-ipython-shell-complete-test failed")
(message "%s" "arbeit-python-epd_free-7.1-2-rh5-x86-bin-ipython-shell-complete-test passed")))
(provide 'py-shell-completion-tests)
;;; py-shell-completion-tests ends here
|