@@ -469,29 +469,46 @@ should have PROP with VAL."
469469(defvar jupyter-org-test-buffer nil
470470 " `org-mode' buffer for testing Jupyter source blocks." )
471471
472+ (defun jupyter-org-test-block (lang code &rest args )
473+ (let ((arg-str (mapconcat
474+ (lambda (x )
475+ (cl-destructuring-bind (name . val) x
476+ (concat (symbol-name name) " " (format " %s " val))))
477+ args " " )))
478+ (concat
479+ " #+BEGIN_SRC jupyter-" lang " " arg-str " :session " jupyter-org-test-session " \n "
480+ code " \n "
481+ " #+END_SRC" )))
482+
472483(defun jupyter-org-test-setup ()
473484 (unless jupyter-org-test-session
474- (require 'org )
475- (setq org-babel-load-languages
476- '((python . t )
477- (jupyter . t )))
478- (setq org-confirm-babel-evaluate nil )
479485 (setq jupyter-org-test-session (make-temp-name " ob-jupyter-test" ))
486+ (setq org-confirm-babel-evaluate nil )
487+ (setq inferior-julia-program-name " julia" )
488+ (require 'org )
489+ (require 'ob-python )
490+ (require 'ob-julia nil t )
491+ (require 'ob-jupyter ))
492+ (unless jupyter-org-test-buffer
480493 (setq jupyter-org-test-buffer (get-buffer-create " ob-jupyter-test" ))
481- (org-babel-do-load-languages
482- 'org-babel-load-languages
483- org-babel-load-languages)
484494 (with-current-buffer jupyter-org-test-buffer
485- (org-mode )
486- (insert
487- " #+BEGIN_SRC jupyter-python " " :session " jupyter-org-test-session " \n "
488- " #+END_SRC" )
489- (setq jupyter-current-client
490- (with-current-buffer (org-babel-initiate-session )
491- jupyter-current-client))))
495+ (org-mode )))
492496 (with-current-buffer jupyter-org-test-buffer
493497 (erase-buffer )))
494498
499+ (defun jupyter-org-test-client-from-info (info )
500+ (let ((params (nth 2 info)))
501+ (with-current-buffer
502+ (org-babel-jupyter-initiate-session
503+ (alist-get :session params) params)
504+ jupyter-current-client)))
505+
506+ (defun jupyter-org-test-session-client (lang )
507+ (jupyter-org-test-setup)
508+ (with-current-buffer jupyter-org-test-buffer
509+ (insert (jupyter-org-test-block lang " " ))
510+ (jupyter-org-test-client-from-info (org-babel-get-src-block-info ))))
511+
495512(defmacro jupyter-org-test (&rest body )
496513 (declare (debug (body)))
497514 `(progn
@@ -536,11 +553,12 @@ results instead of an equality match."
536553 (insert src-block)
537554 (let* ((info (org-babel-get-src-block-info )))
538555 (save-window-excursion
539- (org-babel-execute-src-block nil info))
540- (org-with-point-at (org-babel-where-is-src-block-result nil info)
556+ (org-babel-execute-src-block nil info)
541557 (when (equal (alist-get :async args) " yes" )
542- (jupyter-wait-until-idle
543- (jupyter-last-sent-request jupyter-current-client)))
558+ (jupyter-idle-sync
559+ (jupyter-last-sent-request
560+ (jupyter-org-test-client-from-info info)))))
561+ (org-with-point-at (org-babel-where-is-src-block-result nil info)
544562 (let ((element (org-element-context )))
545563 ; ; Handle empty results with just a RESULTS keyword
546564 ; ;
0 commit comments