# 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
|
|
72 | 72 | |
73 | 73 | ################################################################### |
74 | 74 | |
75 | | from sage.ext.c_lib import _init_csage, sig_on_count |
76 | | _init_csage() |
| 75 | import sage.ext.c_lib |
| 76 | sage.ext.c_lib._init_csage() |
| 77 | sig_on_count = sage.ext.c_lib._sig_on_reset |
77 | 78 | |
78 | 79 | from time import sleep |
79 | 80 | |
diff --git a/sage/doctest/sources.py b/sage/doctest/sources.py
a
|
b
|
|
674 | 674 | There are 12 tests in sage/combinat/tableau.py that are not being run |
675 | 675 | There are 3 unexpected tests being run in sage/doctest/parsing.py |
676 | 676 | 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 |
678 | 677 | There are 9 tests in sage/graphs/graph_plot.py that are not being run |
679 | 678 | There are 2 tests in sage/server/notebook/worksheet.py that are not being run |
680 | 679 | doctest:229: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal |
diff --git a/sage/doctest/test.py b/sage/doctest/test.py
a
|
b
|
|
209 | 209 | ... |
210 | 210 | 16 |
211 | 211 | |
| 212 | Test 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 | |
212 | 236 | Test the ``--debug`` option:: |
213 | 237 | |
214 | 238 | sage: subprocess.call(["sage", "-t", "--debug", "simple_failure.rst"], stdin=open(os.devnull), **kwds) # long time |
diff --git a/sage/doctest/tests/sig_on.rst b/sage/doctest/tests/sig_on.rst
new file mode 100644
-
|
+
|
|
| 1 | Test a bad value of ``sig_on_count``:: |
| 2 | |
| 3 | sage: cython('sig_on()') |
| 4 | |
| 5 | The following test should succees as usual:: |
| 6 | |
| 7 | sage: 3**12 - 2**19 |
| 8 | 7153 |
diff --git a/sage/ext/c_lib.pyx b/sage/ext/c_lib.pyx
a
|
b
|
|
43 | 43 | init_csage() |
44 | 44 | |
45 | 45 | |
46 | | def sig_on_count(): |
| 46 | def _sig_on_reset(): |
47 | 47 | """ |
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. |
53 | 50 | |
54 | 51 | EXAMPLES:: |
55 | 52 | |
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() |
57 | 57 | 0 |
58 | 58 | """ |
59 | | return _signals.sig_on_count |
| 59 | cdef int s = _signals.sig_on_count |
| 60 | _signals.sig_on_count = 0 |
| 61 | return s |
60 | 62 | |
61 | 63 | |
62 | 64 | def sage_python_check_interrupt(sig, frame): |