[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retrieve comint-process output from ert test.

From: Fabian Ezequiel Gallina
Subject: Retrieve comint-process output from ert test.
Date: Thu, 21 Feb 2013 18:18:54 -0300

As I'm moving forward into getting most of python.el covered by tests
I got to a road block I can't solve.

I'm trying to send some arbitrary stuff via python-shell-send-region
(which ends up calling comint-send-string) and retrieve the resulting
output from it.

>From my understanding accept-process-output should do the trick, but I
cannot make it work reliably and I ended up trying things till it
worked, the result is that I needed to call "(sleep-for 1)" two times
in order to get the output I wanted (surprisingly "(sleep-for 2)"
wouldn't help).

This is totally error prone, but it's the only solution I found, so
the question is: what's the good, reliable way to do this?.

Here's the code snippet I'm using to test this behavior in

    (ert-deftest python-shell-internal-send-region-1 ()
      "Check `python-shell-send-region'."
      :expected-result (if (executable-find python-tests-shell-interpreter)

    import inspect
    def hello():
        '''prints hello'''
        print ('hello')
    print ('world')
    print (inspect.getsourcelines(hello))
       (let* ((python-shell-interpreter
               (executable-find python-tests-shell-interpreter))
                (python-shell-get-process-name nil)))
              (process (get-buffer-process shell-buffer)))
         (dotimes (i 3)
           (sleep-for 2)
            (python-tests-look-at "print ('world')" 1 t))
           (accept-process-output process)
           (with-current-buffer shell-buffer
             (should (string=
                       (overlay-start comint-last-prompt-overlay))

Fabián E. Gallina

reply via email to

[Prev in Thread] Current Thread [Next in Thread]