Cleaning up testing

Trying to keep up with jupyter..
This commit is contained in:
John Miller 2016-09-30 13:24:28 -05:00
parent 6ea5c255aa
commit cf70c7ecd9
2 changed files with 19 additions and 17 deletions

View file

@ -39,17 +39,18 @@ Make MAX-COUNT larger \(default 50) to wait longer before timeout."
;; Kill notebook list buffer here to make sure next ;; Kill notebook list buffer here to make sure next
;; `ein:testing-wait-until' works properly. ;; `ein:testing-wait-until' works properly.
(kill-buffer (ein:notebooklist-get-buffer url-or-port)) (kill-buffer (ein:notebooklist-get-buffer url-or-port))
(unless path (setq path "")) (when path
(with-current-buffer (ein:notebooklist-open url-or-port nil) (setq notebook-name (format "%s/%s" path notebook-name)))
(with-current-buffer (ein:notebooklist-open url-or-port path)
(ein:testing-wait-until (lambda () ein:%notebooklist%)) (ein:testing-wait-until (lambda () ein:%notebooklist%))
(prog1 (prog1
(ein:notebooklist-open-notebook-by-name notebook-name) (ein:notebooklist-open-notebook-by-name notebook-name url-or-port)
(ein:log 'debug "TESTING-GET-NOTEBOOK-BY-NAME end")))) (ein:log 'debug "TESTING-GET-NOTEBOOK-BY-NAME end"))))
(defun ein:testing-get-untitled0-or-create (url-or-port &optional path) (defun ein:testing-get-untitled0-or-create (url-or-port &optional path)
(unless path (setq path "")) (unless path (setq path ""))
(ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE start") (ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE start")
(let ((notebook (ein:testing-get-notebook-by-name url-or-port "Untitled0"))) (let ((notebook (ein:testing-get-notebook-by-name url-or-port "Untitled.ipynb")))
(if notebook (if notebook
(progn (ein:log 'debug (progn (ein:log 'debug
"TESTING-GET-UNTITLED0-OR-CREATE notebook already exists") "TESTING-GET-UNTITLED0-OR-CREATE notebook already exists")
@ -63,7 +64,7 @@ Make MAX-COUNT larger \(default 50) to wait longer before timeout."
(setq created t))) (setq created t)))
(ein:testing-wait-until (lambda () created))) (ein:testing-wait-until (lambda () created)))
(prog1 (prog1
(ein:testing-get-notebook-by-name url-or-port "Untitled0" path) (ein:testing-get-notebook-by-name url-or-port "Untitled.ipynb" path)
(ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE end"))))) (ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE end")))))
(defvar ein:notebooklist-after-open-hook nil) (defvar ein:notebooklist-after-open-hook nil)
@ -98,7 +99,7 @@ Make MAX-COUNT larger \(default 50) to wait longer before timeout."
(ein:kernel-live-p it)))) (ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook) (with-current-buffer (ein:notebook-buffer notebook)
(should (equal (ein:$notebook-notebook-name ein:%notebook%) (should (equal (ein:$notebook-notebook-name ein:%notebook%)
"Untitled0")))) "Untitled.ipynb"))))
(ein:log 'verbose "ERT TESTING-GET-UNTITLED0-OR-CREATE end")) (ein:log 'verbose "ERT TESTING-GET-UNTITLED0-OR-CREATE end"))
(ert-deftest ein:testing-delete-untitled0 () (ert-deftest ein:testing-delete-untitled0 ()
@ -112,12 +113,12 @@ Make MAX-COUNT larger \(default 50) to wait longer before timeout."
(lambda () (ein:aand (ein:$notebook-kernel notebook) (lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))) (ein:kernel-live-p it)))))
do (ein:log 'debug "ERT TESTING-DELETE-UNTITLED0 delete notebook") do (ein:log 'debug "ERT TESTING-DELETE-UNTITLED0 delete notebook")
do (ein:testing-delete-notebook-by-name ein:testing-port "Untitled0") do (ein:testing-delete-notebook-by-name ein:testing-port "Untitled.ipynb")
do (ein:log 'debug do (ein:log 'debug
"ERT TESTING-DELETE-UNTITLED0 check the notebook is delete") "ERT TESTING-DELETE-UNTITLED0 check the notebook is delete")
do (let ((num-notebook do (let ((num-notebook
(length (ein:testing-get-notebook-by-name ein:testing-port (length (ein:testing-get-notebook-by-name ein:testing-port
"Untitled0" "Untitled.ipynb"
"")))) ""))))
(should (= num-notebook 0)))) (should (= num-notebook 0))))
(ein:log 'debug "ERT TESTING-DELETE-UNTITLED0 end")) (ein:log 'debug "ERT TESTING-DELETE-UNTITLED0 end"))
@ -165,7 +166,7 @@ See the definition of `create-image' for how it works."
(should (= (length (oref cell :outputs)) 1)) (should (= (length (oref cell :outputs)) 1))
;; This output is a SVG image ;; This output is a SVG image
(let ((out (nth 0 (oref cell :outputs)))) (let ((out (nth 0 (oref cell :outputs))))
(should (equal (plist-get out :output_type) "pyout")) (should (equal (plist-get out :output_type) "execute_result"))
(should (plist-get out :svg)))) (should (plist-get out :svg))))
;; Check the actual output in the buffer: ;; Check the actual output in the buffer:
(save-excursion (save-excursion
@ -184,7 +185,7 @@ See the definition of `create-image' for how it works."
(ein:kernel-live-p it)))) (ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook) (with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below) (call-interactively #'ein:worksheet-insert-cell-below)
(insert "print 'Hello'") (insert "print('Hello')")
(let ((cell (call-interactively #'ein:worksheet-execute-cell))) (let ((cell (call-interactively #'ein:worksheet-execute-cell)))
(ein:testing-wait-until (lambda () (not (oref cell :running))))) (ein:testing-wait-until (lambda () (not (oref cell :running)))))
(save-excursion (save-excursion
@ -202,7 +203,7 @@ See the definition of `create-image' for how it works."
(let ((cell (call-interactively #'ein:worksheet-execute-cell))) (let ((cell (call-interactively #'ein:worksheet-execute-cell)))
(ein:testing-wait-until (lambda () (not (oref cell :running))))) (ein:testing-wait-until (lambda () (not (oref cell :running)))))
(with-current-buffer (get-buffer (ein:$notebook-pager notebook)) (with-current-buffer (get-buffer (ein:$notebook-pager notebook))
(should (search-forward "Docstring:\nrange")))))) (should (search-forward "Docstring:"))))))
(ert-deftest ein:notebook-request-help () (ert-deftest ein:notebook-request-help ()
(let ((notebook (ein:testing-get-untitled0-or-create ein:testing-port))) (let ((notebook (ein:testing-get-untitled0-or-create ein:testing-port)))
@ -219,4 +220,4 @@ See the definition of `create-image' for how it works."
;; Pager buffer will be created when got the response ;; Pager buffer will be created when got the response
(ein:testing-wait-until (lambda () (get-buffer pager-name))) (ein:testing-wait-until (lambda () (get-buffer pager-name)))
(with-current-buffer (get-buffer pager-name) (with-current-buffer (get-buffer pager-name)
(should (search-forward "Docstring:\nfile"))))))) (should (search-forward "Docstring:")))))))

View file

@ -4,16 +4,15 @@
Run EIN test suite Run EIN test suite
""" """
import sys
import os
import glob import glob
import os
import sys
import re
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
import itertools
EIN_ROOT = os.path.normpath( EIN_ROOT = os.path.normpath(
os.path.join(os.path.dirname(__file__), os.path.pardir)) os.path.join(os.path.dirname(__file__), os.path.pardir))
def has_library(emacs, library): def has_library(emacs, library):
""" """
Return True when `emacs` has build-in `library`. Return True when `emacs` has build-in `library`.
@ -88,7 +87,7 @@ class BaseRunner(object):
self.batch = self.batch and not self.debug_on_error self.batch = self.batch and not self.debug_on_error
def logpath(self, name, ext='log'): def logpath(self, name, ext='log'):
return os.path.join( path = os.path.join(
self.log_dir, self.log_dir,
"{testname}_{logname}_{modename}_{emacsname}.{ext}".format( "{testname}_{logname}_{modename}_{emacsname}.{ext}".format(
ext=ext, ext=ext,
@ -97,6 +96,8 @@ class BaseRunner(object):
testname=os.path.splitext(self.testfile)[0], testname=os.path.splitext(self.testfile)[0],
modename='batch' if self.batch else 'interactive', modename='batch' if self.batch else 'interactive',
)) ))
path = re.sub(r'\\', '/', path)
return path
@property @property
def command(self): def command(self):