Ticket #14152: 14152_sig_on_check.patch

File 14152_sig_on_check.patch, 3.7 KB (added by jdemeyer, 7 years ago)
  • sage/all.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1364820450 -7200
    # Node ID f3f9226100674b2510153fb3a4377d794d9c2d10
    # Parent  4faca18e074d2e5770465d950b0a6e5ac2aa448a
    Add a test for sig_on_count()
    
    diff --git a/sage/all.py b/sage/all.py
    a b  
    7272
    7373###################################################################
    7474
    75 from sage.ext.c_lib import _init_csage, sig_on_count
    76 _init_csage()
     75import sage.ext.c_lib
     76sage.ext.c_lib._init_csage()
     77sig_on_count = sage.ext.c_lib._sig_on_reset
    7778
    7879from time                import sleep
    7980
  • sage/doctest/sources.py

    diff --git a/sage/doctest/sources.py b/sage/doctest/sources.py
    a b  
    674674            There are 12 tests in sage/combinat/tableau.py that are not being run
    675675            There are 3 unexpected tests being run in sage/doctest/parsing.py
    676676            There are 1 unexpected tests being run in sage/doctest/reporting.py
    677             There are 1 tests in sage/ext/c_lib.pyx that are not being run
    678677            There are 9 tests in sage/graphs/graph_plot.py that are not being run
    679678            There are 2 tests in sage/server/notebook/worksheet.py that are not being run
    680679            doctest:229: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  • sage/doctest/test.py

    diff --git a/sage/doctest/test.py b/sage/doctest/test.py
    a b  
    209209    ...
    210210    16
    211211
     212Test that ``sig_on_count`` is checked correctly::
     213
     214    sage: subprocess.call(["sage", "-t", "sig_on.rst"], **kwds)  # long time
     215    Running doctests...
     216    Doctesting 1 file.
     217    sage -t sig_on.rst
     218    **********************************************************************
     219    File "sig_on.rst", line 5, in sage.doctest.tests.sig_on
     220    Failed example:
     221        sig_on_count()
     222    Expected:
     223        0
     224    Got:
     225        1
     226    **********************************************************************
     227    1 item had failures:
     228       1 of   4 in sage.doctest.tests.sig_on
     229        [2 tests, 1 failure, ...]
     230    ----------------------------------------------------------------------
     231    sage -t sig_on.rst  # 1 doctest failed
     232    ----------------------------------------------------------------------
     233    ...
     234    1
     235
    212236Test the ``--debug`` option::
    213237
    214238    sage: subprocess.call(["sage", "-t", "--debug", "simple_failure.rst"], stdin=open(os.devnull), **kwds)  # long time
  • new file sage/doctest/tests/sig_on.rst

    diff --git a/sage/doctest/tests/sig_on.rst b/sage/doctest/tests/sig_on.rst
    new file mode 100644
    - +  
     1Test a bad value of ``sig_on_count``::
     2
     3    sage: cython('sig_on()')
     4
     5The following test should succees as usual::
     6
     7    sage: 3**12 - 2**19
     8    7153
  • sage/ext/c_lib.pyx

    diff --git a/sage/ext/c_lib.pyx b/sage/ext/c_lib.pyx
    a b  
    4343    init_csage()
    4444
    4545
    46 def sig_on_count():
     46def _sig_on_reset():
    4747    """
    48     Return _signals.sig_on_count.
    49 
    50     This is normally zero, but increased by every sig_on() or sig_str()
    51     and decreased by every sig_off(). In pure Python code, this should
    52     always be zero.
     48    Return the current value of ``_signals.sig_on_count`` and set its
     49    value to zero. This is used by the doctesting framework.
    5350
    5451    EXAMPLES::
    5552
    56         sage: sig_on_count()
     53        sage: from sage.ext.c_lib import _sig_on_reset as sig_on_reset
     54        sage: cython('sig_on()'); sig_on_reset()
     55        1
     56        sage: sig_on_reset()
    5757        0
    5858    """
    59     return _signals.sig_on_count
     59    cdef int s = _signals.sig_on_count
     60    _signals.sig_on_count = 0
     61    return s
    6062
    6163
    6264def sage_python_check_interrupt(sig, frame):