Skip to content

Commit

Permalink
new versioned python-shell commands: tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-roehler committed Mar 9, 2015
1 parent fd1e118 commit af55b71
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
33 changes: 31 additions & 2 deletions devel/python-mode-utils.el
Expand Up @@ -1145,7 +1145,7 @@ Switch to output buffer; ignores `py-switch-buffers-on-execute-p'. \"
"Reads py-shells, provides commands opening these shell. "
(interactive)
(with-current-buffer
(set-buffer (get-buffer-create "python-components-named-shells.el"))
(get-buffer-create "python-components-named-shells.el")
(erase-buffer)
(insert ";;; Python named shells")
(insert arkopf)
Expand Down Expand Up @@ -1236,7 +1236,7 @@ Optional \\\\[universal-argument] prompts for path to the"))
(defun py-write-installed-shells-menu ()
(interactive)
(with-current-buffer
(set-buffer (get-buffer-create "python-components-installed-shells-menu.el"))
(get-buffer-create "python-components-installed-shells-menu.el")
(erase-buffer)
(when (interactive-p) (switch-to-buffer (current-buffer))
(emacs-lisp-mode))
Expand Down Expand Up @@ -1274,6 +1274,35 @@ Optional \\\\[universal-argument] prompts for path to the"))
(emacs-lisp-mode))
(write-file (concat py-install-directory "/devel/python-components-installed-shells-menu.el"))))

(defun py-write-installed-shells-test-intern ()
(dolist (ele py-shells)
(setq ele (replace-regexp-in-string "\\\\" "" (prin1-to-string ele)))
(insert (concat "\n(ert-deftest " ele))
;; (pmu-fix-ipython)
;; (when arg (insert (concat "-" arg)))
(insert (concat "-shell-test ()
(py-kill-buffer-unconditional \"*" (capitalize ele)))
(pmu-fix-ipython)
;; (when arg (insert (concat "-" arg)))
(insert (concat "*\")
(" ele ")
(should (buffer-live-p (get-buffer \"*" (capitalize ele)))
(pmu-fix-ipython)
;; (when arg (insert (concat "-" arg)))
(insert "*\"))))\n")))

(defun py-write-installed-shells-test ()
(interactive)
(with-current-buffer
(get-buffer-create "python-components-installed-shells-test.el")
(erase-buffer)
(when (interactive-p) (switch-to-buffer (current-buffer))
(emacs-lisp-mode))
(py-write-installed-shells-test-intern)
(when (interactive-p) (switch-to-buffer (current-buffer))
(emacs-lisp-mode))
(write-file (concat py-install-directory "/test/python-components-installed-shells-test.el"))))

(defun py-write-re-beg-end-forms ()
(interactive)
(set-buffer (get-buffer-create "python-components-re-forms.el"))
Expand Down
36 changes: 36 additions & 0 deletions test/py-ert-tests-1.el
Expand Up @@ -1033,5 +1033,41 @@ with file(\"foo\" + zeit + \".ending\", 'w') as datei:
(let ((py-shell-name "python"))
(should (string= "pdb" (py--pdb-versioned))))))

;; shell-tests
(ert-deftest python-shell-test ()
(py-kill-buffer-unconditional "*Python*")
(python)
(should (buffer-live-p (get-buffer "*Python*"))))

(ert-deftest python2-shell-test ()
(py-kill-buffer-unconditional "*Python2*")
(python2)
(should (buffer-live-p (get-buffer "*Python2*"))))

(ert-deftest python3-shell-test ()
(py-kill-buffer-unconditional "*Python3*")
(python3)
(should (buffer-live-p (get-buffer "*Python3*"))))

(ert-deftest ipython-shell-test ()
(py-kill-buffer-unconditional "*IPython*")
(ipython)
(should (buffer-live-p (get-buffer "*IPython*"))))

(ert-deftest ipython2.7-shell-test ()
(py-kill-buffer-unconditional "*IPython2.7*")
(ipython2.7)
(should (buffer-live-p (get-buffer "*IPython2.7*"))))

(ert-deftest ipython3-shell-test ()
(py-kill-buffer-unconditional "*IPython3*")
(ipython3)
(should (buffer-live-p (get-buffer "*IPython3*"))))

(ert-deftest jython-shell-test ()
(py-kill-buffer-unconditional "*Jython*")
(jython)
(should (buffer-live-p (get-buffer "*Jython*"))))

(provide 'py-ert-tests-1)
;;; py-ert-tests-1.el ends here

0 comments on commit af55b71

Please sign in to comment.