Add test for jupyter-connect-repl

This commit is contained in:
Nathaniel Nicandro 2019-04-15 20:47:20 -05:00
parent 9d39fbeaff
commit 9dc814e38a
No known key found for this signature in database
GPG key ID: C34814B309DD06B8
2 changed files with 25 additions and 4 deletions

View file

@ -404,10 +404,12 @@ called if needed.")
(if (eq channel :hb) (jupyter-stop-channel (oref comm hb)) (if (eq channel :hb) (jupyter-stop-channel (oref comm hb))
(with-slots (ioloop) comm (with-slots (ioloop) comm
(jupyter-send ioloop 'stop-channel channel) (jupyter-send ioloop 'stop-channel channel)
;; TODO: Figure out why tests now need a longer timeout sometimes.
(let ((jupyter-default-timeout jupyter-long-timeout))
;; Verify that the channel stops ;; Verify that the channel stops
(or (jupyter-ioloop-wait-until ioloop 'stop-channel (or (jupyter-ioloop-wait-until ioloop 'stop-channel
(lambda (_) (not (jupyter-channel-alive-p comm channel)))) (lambda (_) (not (jupyter-channel-alive-p comm channel))))
(error "Channel not stopped in ioloop subprocess")))))) (error "Channel not stopped in ioloop subprocess (%s)" channel)))))))
(cl-defmethod jupyter-start-channel ((comm jupyter-channel-ioloop-comm) channel) (cl-defmethod jupyter-start-channel ((comm jupyter-channel-ioloop-comm) channel)
(unless (jupyter-channel-alive-p comm channel) (unless (jupyter-channel-alive-p comm channel)

View file

@ -1278,6 +1278,25 @@ last element being the newest element added to the history."
(when (buffer-live-p buffer) (when (buffer-live-p buffer)
(kill-buffer buffer)))))) (kill-buffer buffer))))))
(ert-deftest jupyter-connect-repl ()
:tags '(repl)
(jupyter-test-with-python-repl client
(let ((client (jupyter-connect-repl
(jupyter-session-conn-info
(oref client session)))))
(unwind-protect
(let ((msg (jupyter-wait-until-received :execute-result
(let ((jupyter-inhibit-handlers t))
(jupyter-send-execute-request client
:code "1 + 1")))))
(should msg)
(should (equal (jupyter-message-data msg :text/plain) "2")))
(cl-letf (((symbol-function 'yes-or-no-p)
(lambda (_prompt) t))
((symbol-function 'y-or-n-p)
(lambda (_prompt) t)))
(kill-buffer (oref client buffer)))))))
;;; `org-mode' ;;; `org-mode'
(defvar org-babel-jupyter-resource-directory nil) (defvar org-babel-jupyter-resource-directory nil)