passagemath-repl 10.4.62__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_repl-10.4.62.data/scripts/sage-cachegrind +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-callgrind +16 -0
- passagemath_repl-10.4.62.data/scripts/sage-cleaner +230 -0
- passagemath_repl-10.4.62.data/scripts/sage-coverage +327 -0
- passagemath_repl-10.4.62.data/scripts/sage-eval +14 -0
- passagemath_repl-10.4.62.data/scripts/sage-fixdoctests +708 -0
- passagemath_repl-10.4.62.data/scripts/sage-inline-fortran +12 -0
- passagemath_repl-10.4.62.data/scripts/sage-ipynb2rst +50 -0
- passagemath_repl-10.4.62.data/scripts/sage-ipython +16 -0
- passagemath_repl-10.4.62.data/scripts/sage-massif +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-notebook +267 -0
- passagemath_repl-10.4.62.data/scripts/sage-omega +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-preparse +302 -0
- passagemath_repl-10.4.62.data/scripts/sage-run +27 -0
- passagemath_repl-10.4.62.data/scripts/sage-run-cython +10 -0
- passagemath_repl-10.4.62.data/scripts/sage-runtests +9 -0
- passagemath_repl-10.4.62.data/scripts/sage-startuptime.py +163 -0
- passagemath_repl-10.4.62.data/scripts/sage-valgrind +34 -0
- passagemath_repl-10.4.62.dist-info/METADATA +77 -0
- passagemath_repl-10.4.62.dist-info/RECORD +162 -0
- passagemath_repl-10.4.62.dist-info/WHEEL +5 -0
- passagemath_repl-10.4.62.dist-info/top_level.txt +1 -0
- sage/all__sagemath_repl.py +119 -0
- sage/doctest/__init__.py +4 -0
- sage/doctest/__main__.py +236 -0
- sage/doctest/all.py +4 -0
- sage/doctest/check_tolerance.py +261 -0
- sage/doctest/control.py +1727 -0
- sage/doctest/external.py +534 -0
- sage/doctest/fixtures.py +383 -0
- sage/doctest/forker.py +2665 -0
- sage/doctest/marked_output.py +102 -0
- sage/doctest/parsing.py +1708 -0
- sage/doctest/parsing_test.py +79 -0
- sage/doctest/reporting.py +733 -0
- sage/doctest/rif_tol.py +124 -0
- sage/doctest/sources.py +1657 -0
- sage/doctest/test.py +584 -0
- sage/doctest/tests/1second.rst +4 -0
- sage/doctest/tests/99seconds.rst +4 -0
- sage/doctest/tests/abort.rst +5 -0
- sage/doctest/tests/atexit.rst +7 -0
- sage/doctest/tests/fail_and_die.rst +6 -0
- sage/doctest/tests/initial.rst +15 -0
- sage/doctest/tests/interrupt.rst +7 -0
- sage/doctest/tests/interrupt_diehard.rst +14 -0
- sage/doctest/tests/keyboardinterrupt.rst +11 -0
- sage/doctest/tests/longtime.rst +5 -0
- sage/doctest/tests/nodoctest +5 -0
- sage/doctest/tests/random_seed.rst +4 -0
- sage/doctest/tests/show_skipped.rst +18 -0
- sage/doctest/tests/sig_on.rst +9 -0
- sage/doctest/tests/simple_failure.rst +8 -0
- sage/doctest/tests/sleep_and_raise.rst +106 -0
- sage/doctest/tests/tolerance.rst +31 -0
- sage/doctest/util.py +750 -0
- sage/interfaces/cleaner.py +48 -0
- sage/interfaces/quit.py +163 -0
- sage/misc/all__sagemath_repl.py +51 -0
- sage/misc/banner.py +235 -0
- sage/misc/benchmark.py +221 -0
- sage/misc/classgraph.py +131 -0
- sage/misc/copying.py +22 -0
- sage/misc/cython.py +694 -0
- sage/misc/dev_tools.py +745 -0
- sage/misc/edit_module.py +304 -0
- sage/misc/explain_pickle.py +3079 -0
- sage/misc/gperftools.py +361 -0
- sage/misc/inline_fortran.py +212 -0
- sage/misc/messaging.py +86 -0
- sage/misc/pager.py +21 -0
- sage/misc/profiler.py +179 -0
- sage/misc/python.py +70 -0
- sage/misc/remote_file.py +53 -0
- sage/misc/sage_eval.py +246 -0
- sage/misc/sage_input.py +3621 -0
- sage/misc/sagedoc.py +1742 -0
- sage/misc/sh.py +38 -0
- sage/misc/trace.py +90 -0
- sage/repl/__init__.py +16 -0
- sage/repl/all.py +15 -0
- sage/repl/attach.py +625 -0
- sage/repl/configuration.py +186 -0
- sage/repl/display/__init__.py +1 -0
- sage/repl/display/fancy_repr.py +354 -0
- sage/repl/display/formatter.py +318 -0
- sage/repl/display/jsmol_iframe.py +290 -0
- sage/repl/display/pretty_print.py +153 -0
- sage/repl/display/util.py +163 -0
- sage/repl/image.py +302 -0
- sage/repl/inputhook.py +91 -0
- sage/repl/interface_magic.py +298 -0
- sage/repl/interpreter.py +854 -0
- sage/repl/ipython_extension.py +593 -0
- sage/repl/ipython_kernel/__init__.py +1 -0
- sage/repl/ipython_kernel/__main__.py +4 -0
- sage/repl/ipython_kernel/all_jupyter.py +10 -0
- sage/repl/ipython_kernel/install.py +301 -0
- sage/repl/ipython_kernel/interact.py +278 -0
- sage/repl/ipython_kernel/kernel.py +217 -0
- sage/repl/ipython_kernel/widgets.py +466 -0
- sage/repl/ipython_kernel/widgets_sagenb.py +587 -0
- sage/repl/ipython_tests.py +163 -0
- sage/repl/load.py +326 -0
- sage/repl/preparse.py +2218 -0
- sage/repl/prompts.py +90 -0
- sage/repl/rich_output/__init__.py +4 -0
- sage/repl/rich_output/backend_base.py +648 -0
- sage/repl/rich_output/backend_doctest.py +316 -0
- sage/repl/rich_output/backend_emacs.py +151 -0
- sage/repl/rich_output/backend_ipython.py +596 -0
- sage/repl/rich_output/buffer.py +311 -0
- sage/repl/rich_output/display_manager.py +829 -0
- sage/repl/rich_output/example.avi +0 -0
- sage/repl/rich_output/example.canvas3d +1 -0
- sage/repl/rich_output/example.dvi +0 -0
- sage/repl/rich_output/example.flv +0 -0
- sage/repl/rich_output/example.gif +0 -0
- sage/repl/rich_output/example.jpg +0 -0
- sage/repl/rich_output/example.mkv +0 -0
- sage/repl/rich_output/example.mov +0 -0
- sage/repl/rich_output/example.mp4 +0 -0
- sage/repl/rich_output/example.ogv +0 -0
- sage/repl/rich_output/example.pdf +0 -0
- sage/repl/rich_output/example.png +0 -0
- sage/repl/rich_output/example.svg +54 -0
- sage/repl/rich_output/example.webm +0 -0
- sage/repl/rich_output/example.wmv +0 -0
- sage/repl/rich_output/example_jmol.spt.zip +0 -0
- sage/repl/rich_output/example_wavefront_scene.mtl +7 -0
- sage/repl/rich_output/example_wavefront_scene.obj +17 -0
- sage/repl/rich_output/output_basic.py +391 -0
- sage/repl/rich_output/output_browser.py +103 -0
- sage/repl/rich_output/output_catalog.py +54 -0
- sage/repl/rich_output/output_graphics.py +320 -0
- sage/repl/rich_output/output_graphics3d.py +345 -0
- sage/repl/rich_output/output_video.py +231 -0
- sage/repl/rich_output/preferences.py +432 -0
- sage/repl/rich_output/pretty_print.py +339 -0
- sage/repl/rich_output/test_backend.py +201 -0
- sage/repl/user_globals.py +214 -0
- sage/tests/__init__.py +1 -0
- sage/tests/all.py +3 -0
- sage/tests/article_heuberger_krenn_kropf_fsm-in-sage.py +630 -0
- sage/tests/arxiv_0812_2725.py +351 -0
- sage/tests/benchmark.py +1923 -0
- sage/tests/book_schilling_zabrocki_kschur_primer.py +795 -0
- sage/tests/book_stein_ent.py +651 -0
- sage/tests/book_stein_modform.py +558 -0
- sage/tests/cmdline.py +790 -0
- sage/tests/combinatorial_hopf_algebras.py +52 -0
- sage/tests/finite_poset.py +623 -0
- sage/tests/functools_partial_src.py +27 -0
- sage/tests/gosper-sum.py +218 -0
- sage/tests/lazy_imports.py +28 -0
- sage/tests/modular_group_cohomology.py +80 -0
- sage/tests/numpy.py +21 -0
- sage/tests/parigp.py +76 -0
- sage/tests/startup.py +27 -0
- sage/tests/symbolic-series.py +76 -0
- sage/tests/sympy.py +16 -0
- sage/tests/test_deprecation.py +31 -0
sage/doctest/test.py
ADDED
@@ -0,0 +1,584 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
Test the doctesting framework
|
4
|
+
|
5
|
+
Many tests (with expected failures or crashes) are run in a
|
6
|
+
subprocess, those tests can be found in the ``tests/`` subdirectory.
|
7
|
+
|
8
|
+
EXAMPLES::
|
9
|
+
|
10
|
+
sage: import signal
|
11
|
+
sage: import subprocess
|
12
|
+
sage: import time
|
13
|
+
sage: from sage.env import SAGE_SRC
|
14
|
+
sage: tests_dir = os.path.join(SAGE_SRC, 'sage', 'doctest', 'tests')
|
15
|
+
sage: tests_env = dict(os.environ)
|
16
|
+
|
17
|
+
Unset :envvar:`TERM` when running doctests, see :issue:`14370`::
|
18
|
+
|
19
|
+
sage: try:
|
20
|
+
....: del tests_env['TERM']
|
21
|
+
....: except KeyError:
|
22
|
+
....: pass
|
23
|
+
sage: kwds = {'cwd': tests_dir, 'env':tests_env}
|
24
|
+
|
25
|
+
Check that :issue:`2235` has been fixed::
|
26
|
+
|
27
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
28
|
+
....: "--random-seed=0", "--optional=sage", "longtime.rst"], **kwds)
|
29
|
+
Running doctests...
|
30
|
+
Doctesting 1 file.
|
31
|
+
sage -t --warn-long 0.0 --random-seed=0 longtime.rst
|
32
|
+
[0 tests, ...s wall]
|
33
|
+
----------------------------------------------------------------------
|
34
|
+
All tests passed!
|
35
|
+
----------------------------------------------------------------------
|
36
|
+
...
|
37
|
+
0
|
38
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
39
|
+
....: "--random-seed=0", "--optional=sage", "-l", "longtime.rst"], **kwds)
|
40
|
+
Running doctests...
|
41
|
+
Doctesting 1 file.
|
42
|
+
sage -t --long --warn-long 0.0 --random-seed=0 longtime.rst
|
43
|
+
[1 test, ...s wall]
|
44
|
+
----------------------------------------------------------------------
|
45
|
+
All tests passed!
|
46
|
+
----------------------------------------------------------------------
|
47
|
+
...
|
48
|
+
0
|
49
|
+
|
50
|
+
Check handling of tolerances::
|
51
|
+
|
52
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
53
|
+
....: "--random-seed=0", "--optional=sage", "tolerance.rst"], **kwds)
|
54
|
+
Running doctests...
|
55
|
+
Doctesting 1 file.
|
56
|
+
sage -t --warn-long 0.0 --random-seed=0 tolerance.rst
|
57
|
+
**********************************************************************
|
58
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
59
|
+
Failed example:
|
60
|
+
print(":-(") # abs tol 0.1
|
61
|
+
Expected:
|
62
|
+
:-)
|
63
|
+
Got:
|
64
|
+
:-(
|
65
|
+
**********************************************************************
|
66
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
67
|
+
Failed example:
|
68
|
+
print("1.0 2.0 3.0") # abs tol 0.1
|
69
|
+
Expected:
|
70
|
+
4.0 5.0
|
71
|
+
Got:
|
72
|
+
1.0 2.0 3.0
|
73
|
+
**********************************************************************
|
74
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
75
|
+
Failed example:
|
76
|
+
print("Hello") # abs tol 0.1
|
77
|
+
Expected:
|
78
|
+
1.0
|
79
|
+
Got:
|
80
|
+
Hello
|
81
|
+
**********************************************************************
|
82
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
83
|
+
Failed example:
|
84
|
+
print("1.0") # abs tol 0.1
|
85
|
+
Expected:
|
86
|
+
Hello
|
87
|
+
Got:
|
88
|
+
1.0
|
89
|
+
**********************************************************************
|
90
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
91
|
+
Failed example:
|
92
|
+
print("Hello 1.1") # abs tol 0.1
|
93
|
+
Expected:
|
94
|
+
Goodbye 1.0
|
95
|
+
Got:
|
96
|
+
Hello 1.1
|
97
|
+
**********************************************************************
|
98
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
99
|
+
Failed example:
|
100
|
+
print("Hello 1.0") # rel tol 1e-6
|
101
|
+
Expected:
|
102
|
+
Goodbye 0.999999
|
103
|
+
Got:
|
104
|
+
Hello 1.0
|
105
|
+
Tolerance exceeded:
|
106
|
+
0.999999 vs 1.0, tolerance 2e-6 > 1e-6
|
107
|
+
**********************************************************************
|
108
|
+
File "tolerance.rst", line ..., in sage.doctest.tests.tolerance
|
109
|
+
Failed example:
|
110
|
+
print("Hello 1.0") # rel tol 1e-6
|
111
|
+
Expected:
|
112
|
+
Hello ...
|
113
|
+
Got:
|
114
|
+
Hello 1.0
|
115
|
+
Note: combining tolerance (# tol) with ellipsis (...) is not supported
|
116
|
+
**********************************************************************
|
117
|
+
...
|
118
|
+
1
|
119
|
+
|
120
|
+
Test the ``--initial`` option::
|
121
|
+
|
122
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
123
|
+
....: "--random-seed=0", "--optional=sage", "-i", "initial.rst"], **kwds)
|
124
|
+
Running doctests...
|
125
|
+
Doctesting 1 file.
|
126
|
+
sage -t --warn-long 0.0 --random-seed=0 initial.rst
|
127
|
+
**********************************************************************
|
128
|
+
File "initial.rst", line 4, in sage.doctest.tests.initial
|
129
|
+
Failed example:
|
130
|
+
a = binomiak(10,5) # random to test that we still get the exception
|
131
|
+
Exception raised:
|
132
|
+
Traceback (most recent call last):
|
133
|
+
...
|
134
|
+
NameError: name 'binomiak' is not defined
|
135
|
+
**********************************************************************
|
136
|
+
File "initial.rst", line 14, in sage.doctest.tests.initial
|
137
|
+
Failed example:
|
138
|
+
binomial(10,5)
|
139
|
+
Expected:
|
140
|
+
255
|
141
|
+
Got:
|
142
|
+
252
|
143
|
+
**********************************************************************
|
144
|
+
...
|
145
|
+
----------------------------------------------------------------------
|
146
|
+
sage -t --warn-long 0.0 --random-seed=0 initial.rst # 5 doctests failed
|
147
|
+
----------------------------------------------------------------------
|
148
|
+
...
|
149
|
+
1
|
150
|
+
|
151
|
+
Test the ``--exitfirst`` option::
|
152
|
+
|
153
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
154
|
+
....: "--random-seed=0", "--optional=sage", "--exitfirst", "initial.rst"], **kwds)
|
155
|
+
Running doctests...
|
156
|
+
Doctesting 1 file.
|
157
|
+
sage -t --warn-long 0.0 --random-seed=0 initial.rst
|
158
|
+
**********************************************************************
|
159
|
+
File "initial.rst", line 4, in sage.doctest.tests.initial
|
160
|
+
Failed example:
|
161
|
+
a = binomiak(10,5) # random to test that we still get the exception
|
162
|
+
Exception raised:
|
163
|
+
Traceback (most recent call last):
|
164
|
+
...
|
165
|
+
NameError: name 'binomiak' is not defined
|
166
|
+
**********************************************************************
|
167
|
+
...
|
168
|
+
----------------------------------------------------------------------
|
169
|
+
sage -t --warn-long 0.0 --random-seed=0 initial.rst # 1 doctest failed
|
170
|
+
----------------------------------------------------------------------
|
171
|
+
...
|
172
|
+
1
|
173
|
+
|
174
|
+
Test a timeout using the ``SAGE_TIMEOUT`` environment variable. Also set
|
175
|
+
``CYSIGNALS_CRASH_NDEBUG`` to help ensure the test times out in a timely
|
176
|
+
manner (:issue:`26912`)::
|
177
|
+
|
178
|
+
sage: from copy import deepcopy
|
179
|
+
sage: kwds2 = deepcopy(kwds)
|
180
|
+
sage: kwds2['env'].update({'SAGE_TIMEOUT': '1', 'CYSIGNALS_CRASH_NDEBUG': '1'})
|
181
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
182
|
+
....: "--random-seed=0", "--optional=sage", "99seconds.rst"], **kwds2)
|
183
|
+
Running doctests...
|
184
|
+
Doctesting 1 file.
|
185
|
+
sage -t --warn-long 0.0 --random-seed=0 99seconds.rst
|
186
|
+
Timed out
|
187
|
+
**********************************************************************
|
188
|
+
Tests run before process (pid=...) timed out:
|
189
|
+
...
|
190
|
+
----------------------------------------------------------------------
|
191
|
+
sage -t --warn-long 0.0 --random-seed=0 99seconds.rst # Timed out
|
192
|
+
----------------------------------------------------------------------
|
193
|
+
...
|
194
|
+
4
|
195
|
+
|
196
|
+
Test handling of ``KeyboardInterrupt`` in doctests::
|
197
|
+
|
198
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
199
|
+
....: "--random-seed=0", "--optional=sage", "keyboardinterrupt.rst"], **kwds)
|
200
|
+
Running doctests...
|
201
|
+
Doctesting 1 file.
|
202
|
+
sage -t --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst
|
203
|
+
**********************************************************************
|
204
|
+
File "keyboardinterrupt.rst", line 11, in sage.doctest.tests.keyboardinterrupt
|
205
|
+
Failed example:
|
206
|
+
raise KeyboardInterrupt
|
207
|
+
Exception raised:
|
208
|
+
Traceback (most recent call last):
|
209
|
+
...
|
210
|
+
KeyboardInterrupt
|
211
|
+
**********************************************************************
|
212
|
+
...
|
213
|
+
----------------------------------------------------------------------
|
214
|
+
sage -t --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst # 1 doctest failed
|
215
|
+
----------------------------------------------------------------------
|
216
|
+
...
|
217
|
+
1
|
218
|
+
|
219
|
+
Interrupt the doctester::
|
220
|
+
|
221
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
222
|
+
....: "--random-seed=0", "--optional=sage", "interrupt.rst"], **kwds)
|
223
|
+
Running doctests...
|
224
|
+
Doctesting 1 file.
|
225
|
+
Killing test interrupt.rst
|
226
|
+
----------------------------------------------------------------------
|
227
|
+
Doctests interrupted: 0/1 files tested
|
228
|
+
----------------------------------------------------------------------
|
229
|
+
...
|
230
|
+
128
|
231
|
+
|
232
|
+
Interrupt the doctester (while parallel testing) when a doctest cannot
|
233
|
+
be interrupted. We also test that passing a ridiculous number of threads
|
234
|
+
doesn't hurt::
|
235
|
+
|
236
|
+
sage: F = tmp_filename()
|
237
|
+
sage: from copy import deepcopy
|
238
|
+
sage: kwds2 = deepcopy(kwds)
|
239
|
+
sage: kwds2['env']['DOCTEST_TEST_PID_FILE'] = F # Doctester will write its PID in this file
|
240
|
+
sage: subprocess.call(["sage", "-tp", "1000000", "--timeout=120", # long time
|
241
|
+
....: "--die_timeout=10", "--optional=sage",
|
242
|
+
....: "--warn-long", "0", "99seconds.rst", "interrupt_diehard.rst"], **kwds2)
|
243
|
+
Running doctests...
|
244
|
+
Doctesting 2 files using 1000000 threads...
|
245
|
+
Killing test 99seconds.rst
|
246
|
+
Killing test interrupt_diehard.rst
|
247
|
+
----------------------------------------------------------------------
|
248
|
+
Doctests interrupted: 0/2 files tested
|
249
|
+
----------------------------------------------------------------------
|
250
|
+
...
|
251
|
+
128
|
252
|
+
|
253
|
+
Even though the doctester master process has exited, the child process
|
254
|
+
is still alive, but it should be killed automatically
|
255
|
+
after the ``die_timeout`` given above (10 seconds)::
|
256
|
+
|
257
|
+
sage: # long time
|
258
|
+
sage: pid = int(open(F).read())
|
259
|
+
sage: time.sleep(2)
|
260
|
+
sage: os.kill(pid, signal.SIGQUIT) # 2 seconds passed => still alive
|
261
|
+
sage: time.sleep(8)
|
262
|
+
sage: os.kill(pid, signal.SIGQUIT) # 10 seconds passed => dead # random
|
263
|
+
Traceback (most recent call last):
|
264
|
+
...
|
265
|
+
ProcessLookupError: ...
|
266
|
+
|
267
|
+
If the child process is dead and removed, the last output should be as above.
|
268
|
+
However, the child process interrupted its parent process (see
|
269
|
+
``'interrupt_diehard.rst'``), and became an orphan process. Depending on the
|
270
|
+
system, an orphan process may eventually become a zombie process instead of
|
271
|
+
being removed, and then the last output would just be a blank. Hence the ``#
|
272
|
+
random`` tag.
|
273
|
+
|
274
|
+
Test a doctest failing with ``abort()``::
|
275
|
+
|
276
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
277
|
+
....: "--random-seed=0", "--optional=sage", "abort.rst"], **kwds)
|
278
|
+
Running doctests...
|
279
|
+
Doctesting 1 file.
|
280
|
+
sage -t --warn-long 0.0 --random-seed=0 abort.rst
|
281
|
+
Killed due to abort
|
282
|
+
**********************************************************************
|
283
|
+
Tests run before process (pid=...) failed:
|
284
|
+
...
|
285
|
+
------------------------------------------------------------------------
|
286
|
+
Unhandled SIGABRT: An abort() occurred.
|
287
|
+
This probably occurred because a *compiled* module has a bug
|
288
|
+
in it and is not properly wrapped with sig_on(), sig_off().
|
289
|
+
Python will now terminate.
|
290
|
+
------------------------------------------------------------------------
|
291
|
+
...
|
292
|
+
----------------------------------------------------------------------
|
293
|
+
sage -t --warn-long 0.0 --random-seed=0 abort.rst # Killed due to abort
|
294
|
+
----------------------------------------------------------------------
|
295
|
+
...
|
296
|
+
16
|
297
|
+
|
298
|
+
A different kind of crash::
|
299
|
+
|
300
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
301
|
+
....: "--random-seed=0", "--optional=sage", "fail_and_die.rst"], **kwds)
|
302
|
+
Running doctests...
|
303
|
+
Doctesting 1 file.
|
304
|
+
sage -t --warn-long 0.0 --random-seed=0 fail_and_die.rst
|
305
|
+
**********************************************************************
|
306
|
+
File "fail_and_die.rst", line 5, in sage.doctest.tests.fail_and_die
|
307
|
+
Failed example:
|
308
|
+
this_gives_a_NameError
|
309
|
+
Exception raised:
|
310
|
+
Traceback (most recent call last):
|
311
|
+
...
|
312
|
+
NameError: name 'this_gives_a_NameError' is not defined
|
313
|
+
Killed due to kill signal
|
314
|
+
**********************************************************************
|
315
|
+
Tests run before process (pid=...) failed:
|
316
|
+
...
|
317
|
+
----------------------------------------------------------------------
|
318
|
+
sage -t --warn-long 0.0 --random-seed=0 fail_and_die.rst # Killed due to kill signal
|
319
|
+
----------------------------------------------------------------------
|
320
|
+
...
|
321
|
+
16
|
322
|
+
|
323
|
+
Test that ``sig_on_count`` is checked correctly::
|
324
|
+
|
325
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
326
|
+
....: "--random-seed=0", "--optional=sage", "sig_on.rst"], **kwds)
|
327
|
+
Running doctests...
|
328
|
+
Doctesting 1 file.
|
329
|
+
sage -t --warn-long 0.0 --random-seed=0 sig_on.rst
|
330
|
+
**********************************************************************
|
331
|
+
File "sig_on.rst", line 6, in sage.doctest.tests.sig_on
|
332
|
+
Failed example:
|
333
|
+
sig_on_count() # check sig_on/off pairings (virtual doctest)
|
334
|
+
Expected:
|
335
|
+
0
|
336
|
+
Got:
|
337
|
+
1
|
338
|
+
**********************************************************************
|
339
|
+
1 item had failures:
|
340
|
+
1 of 5 in sage.doctest.tests.sig_on
|
341
|
+
[3 tests, 1 failure, ...]
|
342
|
+
----------------------------------------------------------------------
|
343
|
+
sage -t --warn-long 0.0 --random-seed=0 sig_on.rst # 1 doctest failed
|
344
|
+
----------------------------------------------------------------------
|
345
|
+
...
|
346
|
+
1
|
347
|
+
|
348
|
+
Test logfiles in serial and parallel mode (see :issue:`19271`)::
|
349
|
+
|
350
|
+
sage: t = tmp_filename()
|
351
|
+
sage: subprocess.call(["sage", "-t", "--serial", "--warn-long", "0", # long time
|
352
|
+
....: "--random-seed=0", "--optional=sage", "--logfile", t, "simple_failure.rst"],
|
353
|
+
....: stdout=open(os.devnull, "w"), **kwds)
|
354
|
+
1
|
355
|
+
sage: print(open(t).read()) # long time
|
356
|
+
Running doctests...
|
357
|
+
Doctesting 1 file.
|
358
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst
|
359
|
+
**********************************************************************
|
360
|
+
File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure
|
361
|
+
Failed example:
|
362
|
+
a * b
|
363
|
+
Expected:
|
364
|
+
20
|
365
|
+
Got:
|
366
|
+
15
|
367
|
+
**********************************************************************
|
368
|
+
1 item had failures:
|
369
|
+
1 of 5 in sage.doctest.tests.simple_failure
|
370
|
+
[4 tests, 1 failure, ...]
|
371
|
+
----------------------------------------------------------------------
|
372
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed
|
373
|
+
----------------------------------------------------------------------
|
374
|
+
...
|
375
|
+
|
376
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
377
|
+
....: "--random-seed=0", "--optional=sage", "--logfile", t, "simple_failure.rst"],
|
378
|
+
....: stdout=open(os.devnull, "w"), **kwds)
|
379
|
+
1
|
380
|
+
sage: print(open(t).read()) # long time
|
381
|
+
Running doctests...
|
382
|
+
Doctesting 1 file.
|
383
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst
|
384
|
+
**********************************************************************
|
385
|
+
File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure
|
386
|
+
Failed example:
|
387
|
+
a * b
|
388
|
+
Expected:
|
389
|
+
20
|
390
|
+
Got:
|
391
|
+
15
|
392
|
+
**********************************************************************
|
393
|
+
1 item had failures:
|
394
|
+
1 of 5 in sage.doctest.tests.simple_failure
|
395
|
+
[4 tests, 1 failure, ...]
|
396
|
+
----------------------------------------------------------------------
|
397
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed
|
398
|
+
----------------------------------------------------------------------
|
399
|
+
...
|
400
|
+
|
401
|
+
Test the ``--debug`` option::
|
402
|
+
|
403
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
404
|
+
....: "--random-seed=0", "--optional=sage", "--debug", "simple_failure.rst"],
|
405
|
+
....: stdin=open(os.devnull), **kwds)
|
406
|
+
Running doctests...
|
407
|
+
Doctesting 1 file.
|
408
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst
|
409
|
+
**********************************************************************
|
410
|
+
File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure
|
411
|
+
Failed example:
|
412
|
+
a * b
|
413
|
+
Expected:
|
414
|
+
20
|
415
|
+
Got:
|
416
|
+
15
|
417
|
+
**********************************************************************
|
418
|
+
Previously executed commands:
|
419
|
+
s...: a = 3
|
420
|
+
s...: b = 5
|
421
|
+
s...: a + b
|
422
|
+
8
|
423
|
+
sage:
|
424
|
+
<BLANKLINE>
|
425
|
+
Returning to doctests...
|
426
|
+
**********************************************************************
|
427
|
+
1 item had failures:
|
428
|
+
1 of 5 in sage.doctest.tests.simple_failure
|
429
|
+
[4 tests, 1 failure, ...]
|
430
|
+
----------------------------------------------------------------------
|
431
|
+
sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed
|
432
|
+
----------------------------------------------------------------------
|
433
|
+
...
|
434
|
+
1
|
435
|
+
|
436
|
+
Test running under gdb, without and with a timeout::
|
437
|
+
|
438
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time, optional: gdb
|
439
|
+
....: "--random-seed=0", "--optional=sage", "--gdb", "1second.rst"],
|
440
|
+
....: stdin=open(os.devnull), **kwds)
|
441
|
+
exec gdb ...
|
442
|
+
Running doctests...
|
443
|
+
Doctesting 1 file...
|
444
|
+
sage -t... 1second.rst...
|
445
|
+
[2 tests, ...s wall]
|
446
|
+
----------------------------------------------------------------------
|
447
|
+
All tests passed!
|
448
|
+
----------------------------------------------------------------------
|
449
|
+
...
|
450
|
+
0
|
451
|
+
|
452
|
+
gdb might need a long time to start up, so we allow 30 seconds::
|
453
|
+
|
454
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time, optional: gdb
|
455
|
+
....: "--random-seed=0", "--optional=sage", "--gdb", "-T30", "99seconds.rst"],
|
456
|
+
....: stdin=open(os.devnull), **kwds)
|
457
|
+
exec gdb ...
|
458
|
+
Running doctests...
|
459
|
+
Timed out
|
460
|
+
4
|
461
|
+
|
462
|
+
Test the ``--show-skipped`` option::
|
463
|
+
|
464
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
465
|
+
....: "--random-seed=0", "--optional=sage", "--show-skipped", "show_skipped.rst"], **kwds)
|
466
|
+
Running doctests ...
|
467
|
+
Doctesting 1 file.
|
468
|
+
sage -t --warn-long 0.0 --random-seed=0 show_skipped.rst
|
469
|
+
2 tests not run due to known bugs
|
470
|
+
1 gap test not run
|
471
|
+
1 long test not run
|
472
|
+
1 not tested test not run
|
473
|
+
0 tests not run because we ran out of time
|
474
|
+
[2 tests, ...s wall]
|
475
|
+
----------------------------------------------------------------------
|
476
|
+
All tests passed!
|
477
|
+
----------------------------------------------------------------------
|
478
|
+
...
|
479
|
+
0
|
480
|
+
|
481
|
+
Optional tests are run correctly::
|
482
|
+
|
483
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", "--long", # long time
|
484
|
+
....: "--random-seed=0", "--show-skipped", "--optional=sage,gap", "show_skipped.rst"], **kwds)
|
485
|
+
Running doctests ...
|
486
|
+
Doctesting 1 file.
|
487
|
+
sage -t --long --warn-long 0.0 --random-seed=0 show_skipped.rst
|
488
|
+
2 tests not run due to known bugs
|
489
|
+
1 not tested test not run
|
490
|
+
0 tests not run because we ran out of time
|
491
|
+
[4 tests, ...s wall]
|
492
|
+
----------------------------------------------------------------------
|
493
|
+
All tests passed!
|
494
|
+
----------------------------------------------------------------------
|
495
|
+
...
|
496
|
+
0
|
497
|
+
|
498
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", "--long", # long time
|
499
|
+
....: "--random-seed=0", "--show-skipped", "--optional=gAp", "show_skipped.rst"], **kwds)
|
500
|
+
Running doctests ...
|
501
|
+
Doctesting 1 file.
|
502
|
+
sage -t --long --warn-long 0.0 --random-seed=0 show_skipped.rst
|
503
|
+
2 tests not run due to known bugs
|
504
|
+
1 not tested test not run
|
505
|
+
2 sage tests not run
|
506
|
+
0 tests not run because we ran out of time
|
507
|
+
[2 tests, ...s wall]
|
508
|
+
----------------------------------------------------------------------
|
509
|
+
All tests passed!
|
510
|
+
----------------------------------------------------------------------
|
511
|
+
...
|
512
|
+
0
|
513
|
+
|
514
|
+
Test an invalid value for ``--optional``::
|
515
|
+
|
516
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0",
|
517
|
+
....: "--random-seed=0", "--optional=bad-option", "show_skipped.rst"], **kwds)
|
518
|
+
Traceback (most recent call last):
|
519
|
+
...
|
520
|
+
ValueError: invalid optional tag 'bad-option'
|
521
|
+
1
|
522
|
+
|
523
|
+
Test ``atexit`` support in the doctesting framework::
|
524
|
+
|
525
|
+
sage: F = tmp_filename()
|
526
|
+
sage: os.path.isfile(F)
|
527
|
+
True
|
528
|
+
sage: from copy import deepcopy
|
529
|
+
sage: kwds2 = deepcopy(kwds)
|
530
|
+
sage: kwds2['env']['DOCTEST_DELETE_FILE'] = F
|
531
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
532
|
+
....: "--random-seed=0", "--optional=sage", "atexit.rst"], **kwds2)
|
533
|
+
Running doctests...
|
534
|
+
Doctesting 1 file.
|
535
|
+
sage -t --warn-long 0.0 --random-seed=0 atexit.rst
|
536
|
+
[3 tests, ...s wall]
|
537
|
+
----------------------------------------------------------------------
|
538
|
+
All tests passed!
|
539
|
+
----------------------------------------------------------------------
|
540
|
+
...
|
541
|
+
0
|
542
|
+
sage: os.path.isfile(F) # long time
|
543
|
+
False
|
544
|
+
sage: try:
|
545
|
+
....: os.unlink(F)
|
546
|
+
....: except OSError:
|
547
|
+
....: pass
|
548
|
+
|
549
|
+
Test that random tests are reproducible::
|
550
|
+
|
551
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
552
|
+
....: "--random-seed=0", "--optional=sage", "random_seed.rst"], **kwds)
|
553
|
+
Running doctests...
|
554
|
+
Doctesting 1 file.
|
555
|
+
sage -t --warn-long 0.0 --random-seed=0 random_seed.rst
|
556
|
+
**********************************************************************
|
557
|
+
File "random_seed.rst", line 3, in sage.doctest.tests.random_seed
|
558
|
+
Failed example:
|
559
|
+
randint(5, 10)
|
560
|
+
Expected:
|
561
|
+
9
|
562
|
+
Got:
|
563
|
+
5
|
564
|
+
**********************************************************************
|
565
|
+
1 item had failures:
|
566
|
+
1 of 2 in sage.doctest.tests.random_seed
|
567
|
+
[1 test, 1 failure, ...s wall]
|
568
|
+
----------------------------------------------------------------------
|
569
|
+
sage -t --warn-long 0.0 --random-seed=0 random_seed.rst # 1 doctest failed
|
570
|
+
----------------------------------------------------------------------
|
571
|
+
...
|
572
|
+
1
|
573
|
+
sage: subprocess.call(["sage", "-t", "--warn-long", "0", # long time
|
574
|
+
....: "--random-seed=1", "--optional=sage", "random_seed.rst"], **kwds)
|
575
|
+
Running doctests...
|
576
|
+
Doctesting 1 file.
|
577
|
+
sage -t --warn-long 0.0 --random-seed=1 random_seed.rst
|
578
|
+
[1 test, ...s wall]
|
579
|
+
----------------------------------------------------------------------
|
580
|
+
All tests passed!
|
581
|
+
----------------------------------------------------------------------
|
582
|
+
...
|
583
|
+
0
|
584
|
+
"""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
One initial typo causes a :exc:`NameError` in the first test and many
|
2
|
+
following failures::
|
3
|
+
|
4
|
+
sage: a = binomiak(10,5) # random to test that we still get the exception
|
5
|
+
sage: a
|
6
|
+
252
|
7
|
+
sage: a == factorial(10)/factorial(5)^2
|
8
|
+
True
|
9
|
+
sage: a//12
|
10
|
+
21
|
11
|
+
|
12
|
+
But this is a new failure::
|
13
|
+
|
14
|
+
sage: binomial(10,5)
|
15
|
+
255
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Save the current PID to the file given by :envvar:DOCTEST_TEST_PID_FILE::
|
2
|
+
|
3
|
+
sage: with open(os.environ['DOCTEST_TEST_PID_FILE'], "w") as file:
|
4
|
+
....: file.write(str(os.getpid()))
|
5
|
+
|
6
|
+
Interrupt the doctester (the parent process) while blocking the quit
|
7
|
+
signal (used to kill this process)::
|
8
|
+
|
9
|
+
sage: import signal
|
10
|
+
sage: import time
|
11
|
+
sage: from cysignals.pselect import PSelecter
|
12
|
+
sage: with PSelecter([signal.SIGQUIT]):
|
13
|
+
....: os.kill(os.getppid(), signal.SIGINT)
|
14
|
+
....: time.sleep(30)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
We explicitly raise an interrupt and expect it::
|
2
|
+
|
3
|
+
sage: raise KeyboardInterrupt
|
4
|
+
Traceback (most recent call last):
|
5
|
+
...
|
6
|
+
KeyboardInterrupt
|
7
|
+
|
8
|
+
We now raise an interrupt without expecting it, which should lead to
|
9
|
+
an ordinary doctest failure::
|
10
|
+
|
11
|
+
sage: raise KeyboardInterrupt
|