Ticket #14426: 14426_doctest.patch

File 14426_doctest.patch, 2.3 KB (added by Jeroen Demeyer, 10 years ago)
  • sage/interfaces/tests.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1365422124 -7200
    # Node ID d158cebb4d85996b08dcb61f77071fee9367ba72
    # Parent  190c98af438d79b5121f1cc8424606e75fcfb43e
    Check that interfaces handle write errors gracefully
    
    diff --git a/sage/interfaces/tests.py b/sage/interfaces/tests.py
    a b  
    2121    4
    2222    sage: parent(a)
    2323    Singular
     24
     25Test that write errors to stderr are handled gracefully by GAP
     26(see :trac:`13211`) and ECL (see :trac:`14426`) and other interfaces::
     27
     28    sage: import subprocess
     29    sage: try:
     30    ....:     f = open('/dev/full', 'w')
     31    ....: except IOError:
     32    ....:     f = open('/dev/null', 'w')
     33    sage: kwds = dict(shell=True, stdout=f, stderr=f)
     34    sage: subprocess.call("echo syntax error | ecl", **kwds)
     35    0
     36    sage: subprocess.call("echo syntax error | gap", **kwds)
     37    0
     38    sage: subprocess.call("echo syntax error | gp", **kwds)
     39    0
     40    sage: subprocess.call("echo syntax error | ipython", **kwds) in (0,1)
     41    True
     42    sage: subprocess.call("echo syntax error | singular", **kwds)
     43    0
    2444"""
    2545
    2646from all import *
  • sage/tests/cmdline.py

    diff --git a/sage/tests/cmdline.py b/sage/tests/cmdline.py
    a b  
    5555import os, select
    5656
    5757
    58 def test_executable(args, input="", timeout=100.0, cwd=None):
     58def test_executable(args, input="", timeout=100.0, **kwds):
    5959    r"""
    6060    Run the program defined by ``args`` using the string ``input`` on
    6161    the standard input.
     
    7171    - ``timeout`` -- if the program produces no output for ``timeout``
    7272      seconds, a RuntimeError is raised.
    7373
    74     - ``cwd`` -- (default: ``None``) if not None, run the program from
    75       the given directory.
     74    - ``**kwds`` -- Additional keyword arguments passed to the
     75      :class:`Popen` constructor.
    7676
    7777    OUTPUT: a tuple ``(out, err, ret)`` with the standard output,
    7878    standard error and exitcode of the program run.
     
    591591        del pexpect_env["TERM"]
    592592    except KeyError:
    593593        pass
    594     p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd, env=pexpect_env)
     594    p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=pexpect_env, **kwds)
    595595    if input:
    596596        p.stdin.write(input)
    597597    p.stdin.close()