diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c4a1207a42..667078613b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -430,7 +430,6 @@ jobs: GH_TOKEN: ${{ github.token }} # Building - - name: Generate Dockerfile # From docker.yml run: | @@ -471,6 +470,7 @@ jobs: --workdir $(pwd) \ ${{ env.BUILD_IMAGE }} /bin/sh + # Combining - name: Download coverage artifacts diff --git a/.github/workflows/ci-conda.yml b/.github/workflows/ci-conda.yml index 4b22d9669a0..e48d445ed4b 100644 --- a/.github/workflows/ci-conda.yml +++ b/.github/workflows/ci-conda.yml @@ -61,6 +61,12 @@ jobs: activate-environment: sage-dev environment-file: ${{ matrix.conda-env }}-${{ matrix.python }}-${{ startsWith(matrix.os, 'macos') && (startsWith(runner.arch, 'ARM') && 'macos' || 'macos-x86_64') || 'linux' }}.yml + - name: Install test tools + shell: bash -l {0} + run: | + conda install -c conda-forge pytest-xdist pytest-github-actions-annotate-failures coverage + pip install pytest-isolate + - name: Print Conda environment shell: bash -l {0} run: | @@ -89,7 +95,7 @@ jobs: - name: Test if: success() || failure() shell: bash -l {0} - run: ./sage -t --all --baseline-stats-path=.github/workflows/ci-conda-known-test-failures.json -p0 + run: ./sage -python -m pytest --doctest-ignore-import-errors --doctest -rfEs -s src - name: Print logs if: always() diff --git a/.github/workflows/ci-meson.yml b/.github/workflows/ci-meson.yml index 79fe228946a..994a3714589 100644 --- a/.github/workflows/ci-meson.yml +++ b/.github/workflows/ci-meson.yml @@ -103,7 +103,8 @@ jobs: # If editable then deleting the directory will cause sage to detect rebuild, which will cause ninja to fail # so we don't delete the directory in this case ${{ matrix.editable && 'true' || 'rm -R ./src/sage_setup/' }} - ./sage -t --all -p4 --format github + pip install coverage pytest-xdist pytest-github-actions-annotate-failures pytest-isolate + pytest --doctest-ignore-import-errors --doctest -rfEs -s src - name: Upload log uses: actions/upload-artifact@v4.5.0 diff --git a/.vscode/settings.json b/.vscode/settings.json index 8998f229f9f..b3ad53bba8b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -31,6 +31,7 @@ "arctanh", "Bejger", "bigcup", + "bitness", "cachefunc", "charpoly", "classmethod", diff --git a/conftest.py b/conftest.py index 5307d7f6233..9f098452b6d 100644 --- a/conftest.py +++ b/conftest.py @@ -138,7 +138,7 @@ def _find( except ModuleNotFoundError as exception: # TODO: Remove this once all optional things are using Features pytest.skip( - f"unable to import module { self.path } due to missing module { exception.name }" + f"unable to import module { self.path } due to missing feature { exception.name }" ) @@ -181,6 +181,9 @@ def pytest_collect_file( if file_path.name == "__main__.py" or file_path.name == "setup.py": # We don't allow tests to be defined in __main__.py/setup.py files (because their import will fail). return IgnoreCollector.from_parent(parent) + if file_path.name == "all.py": + # all.py do not contain tests and may fail when imported twice / in the wrong order + return IgnoreCollector.from_parent(parent) if ( ( file_path.name == "postprocess.py" diff --git a/src/doc/en/developer/doctesting.rst b/src/doc/en/developer/doctesting.rst index a8913b4813a..e7b448c42a6 100644 --- a/src/doc/en/developer/doctesting.rst +++ b/src/doc/en/developer/doctesting.rst @@ -365,8 +365,8 @@ as taking a long time: on machines with "only" 2GB of RAM, we test ``max_n`` = 1, which has a more reasonable memory usage. :: - sage: from sage.crypto.mq.sr import test_consistency - sage: test_consistency(1) # long time (80s on sage.math, 2011) + sage: from sage.crypto.mq.sr import check_consistency + sage: check_consistency(1) # long time (80s on sage.math, 2011) True """ diff --git a/src/sage/algebras/fusion_rings/fusion_ring.py b/src/sage/algebras/fusion_rings/fusion_ring.py index e454b07dfcb..ba3dd1ebc5f 100644 --- a/src/sage/algebras/fusion_rings/fusion_ring.py +++ b/src/sage/algebras/fusion_rings/fusion_ring.py @@ -381,7 +381,7 @@ def _test_total_q_order(self, **options): tester.assertTrue(tqo.is_real_positive()) tester.assertEqual(tqo**2, self.global_q_dimension(base_coercion=False)) - def test_braid_representation(self, max_strands=6, anyon=None): + def check_braid_representation(self, max_strands=6, anyon=None): """ Check that we can compute valid braid group representations. @@ -402,10 +402,10 @@ def test_braid_representation(self, max_strands=6, anyon=None): EXAMPLES:: sage: A21 = FusionRing("A2", 1) - sage: A21.test_braid_representation(max_strands=4) + sage: A21.check_braid_representation(max_strands=4) True sage: F41 = FusionRing("F4", 1) # long time - sage: F41.test_braid_representation() # long time + sage: F41.check_braid_representation() # long time True """ if not self.is_multiplicity_free(): # Braid group representation is not available if self is not multiplicity free diff --git a/src/sage/categories/cartesian_product.py b/src/sage/categories/cartesian_product.py index 2da692abc3c..e4f697745cd 100644 --- a/src/sage/categories/cartesian_product.py +++ b/src/sage/categories/cartesian_product.py @@ -52,6 +52,7 @@ class CartesianProductFunctor(CovariantFunctorialConstruction, MultivariateConst sage: C = cartesian_product([M, ZZ, QQ]) sage: C The Cartesian product of (M, Integer Ring, Rational Field) + sage: M.reset_name() sage: C.an_element() ('abcd', 1, 1/2) sage: C.an_element()^2 diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 5e5b7ec8aff..849f9f0721b 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -2534,11 +2534,11 @@ class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom): # Cat :class:`Category_over_base_ring` becomes automatically a :class:`CategoryWithAxiom_over_base_ring`:: - sage: from sage.categories.category_with_axiom import TestObjectsOverBaseRing, Category_over_base_ring + sage: from sage.categories.category_with_axiom import DummyObjectsOverBaseRing, Category_over_base_ring sage: from sage.categories.category import JoinCategory - sage: isinstance(TestObjectsOverBaseRing(QQ), Category_over_base_ring) + sage: isinstance(DummyObjectsOverBaseRing(QQ), Category_over_base_ring) True - sage: C = TestObjectsOverBaseRing(QQ).Commutative() + sage: C = DummyObjectsOverBaseRing(QQ).Commutative() sage: isinstance(C, Category_over_base_ring) # todo: not implemented True sage: C.FiniteDimensional() @@ -2548,7 +2548,7 @@ class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom): # Cat sage: C.Unital() Category of commutative unital test objects over base ring over Rational Field - sage: C = TestObjectsOverBaseRing(IntegerModRing(2)).Connected() + sage: C = DummyObjectsOverBaseRing(IntegerModRing(2)).Connected() sage: isinstance(C, JoinCategory) True sage: isinstance(C, Category_over_base_ring) # todo: not implemented @@ -2604,7 +2604,7 @@ class Blahs(Category_singleton): - :class:`Bars` - :class:`TestObjects` - - :class:`TestObjectsOverBaseRing` + - :class:`DummyObjectsOverBaseRing` """ def super_categories(self): @@ -2788,7 +2788,7 @@ class Unital(CategoryWithAxiom): pass -class TestObjectsOverBaseRing(Category_over_base_ring): +class DummyObjectsOverBaseRing(Category_over_base_ring): r""" A toy singleton category, for testing purposes. @@ -2799,14 +2799,14 @@ def super_categories(self): """ TESTS:: - sage: from sage.categories.category_with_axiom import TestObjectsOverBaseRing - sage: TestObjectsOverBaseRing(QQ).super_categories() + sage: from sage.categories.category_with_axiom import DummyObjectsOverBaseRing + sage: DummyObjectsOverBaseRing(QQ).super_categories() [Category of test objects] - sage: TestObjectsOverBaseRing.Unital.an_instance() - Category of unital test objects over base ring over Rational Field - sage: TestObjectsOverBaseRing.FiniteDimensional.Unital.an_instance() - Category of finite dimensional unital test objects over base ring over Rational Field - sage: C = TestObjectsOverBaseRing(QQ).FiniteDimensional().Unital().Commutative() + sage: DummyObjectsOverBaseRing.Unital.an_instance() + Category of unital dummy objects over base ring over Rational Field + sage: DummyObjectsOverBaseRing.FiniteDimensional.Unital.an_instance() + Category of finite dimensional unital dummy objects over base ring over Rational Field + sage: C = DummyObjectsOverBaseRing(QQ).FiniteDimensional().Unital().Commutative() sage: TestSuite(C).run() """ return [TestObjects()] diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py index c60202c6f23..66b33160e8b 100644 --- a/src/sage/crypto/mq/sr.py +++ b/src/sage/crypto/mq/sr.py @@ -3298,7 +3298,7 @@ def __exit__(self, typ, value, tb): self.sr._allow_zero_inversions = self.allow_zero_inversions -def test_consistency(max_n=2, **kwargs): +def check_consistency(max_n=2, **kwargs): r""" Test all combinations of ``r``, ``c``, ``e`` and ``n`` in ``(1, 2)`` for consistency of random encryptions and their polynomial @@ -3317,8 +3317,8 @@ def test_consistency(max_n=2, **kwargs): on machines with "only" 2GB of RAM, we test ``max_n`` = 1, which has a more reasonable memory usage. :: - sage: from sage.crypto.mq.sr import test_consistency - sage: test_consistency(1) # long time (65s on sage.math, 2012) + sage: from sage.crypto.mq.sr import check_consistency + sage: check_consistency(1) # long time (65s on sage.math, 2012) True """ consistent = True diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py index 77d3473a21f..3b9aa125dc7 100644 --- a/src/sage/databases/oeis.py +++ b/src/sage/databases/oeis.py @@ -1928,7 +1928,7 @@ def flush_to_table(language, code_lines): return sorted(table) return sorted(prog for la, prog in table if la == language) - def test_compile_sage_code(self): + def check_compile_sage_code(self): """ Try to compile the extracted sage code, if there is any. @@ -1944,13 +1944,13 @@ def test_compile_sage_code(self): One correct sequence:: sage: s = oeis.find_by_id('A027642') # optional -- internet - sage: s.test_compile_sage_code() # optional -- internet + sage: s.check_compile_sage_code() # optional -- internet True One dead sequence:: sage: s = oeis.find_by_id('A000154') # optional -- internet - sage: s.test_compile_sage_code() # optional -- internet + sage: s.check_compile_sage_code() # optional -- internet True """ if self.is_dead(): diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 85af26d20ad..ae06cbbee9d 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -293,7 +293,7 @@ def showwarning_with_traceback(message, category, filename, lineno, file=None, l lines.extend(traceback.format_exception_only(category, category(message))) if file is None: - file = sys.stderr + file = sys.stdout try: file.writelines(lines) file.flush() @@ -517,7 +517,7 @@ def getvalue(self): TestResults = namedtuple('TestResults', 'failed attempted') -class SageDocTestRunner(doctest.DocTestRunner): +class SageDocTestRunner(doctest.DocTestRunner, object): def __init__(self, *args, **kwds): """ A customized version of DocTestRunner that tracks dependencies @@ -706,10 +706,10 @@ def compiler(example): # findlinestarts() returns pairs (index, lineno) where # "index" is the index in the bytecode where the line # number changes to "lineno". - linenumbers1 = {lineno for (index, lineno) - in findlinestarts(code)} - linenumbers2 = {lineno for (index, lineno) - in findlinestarts(execcode)} + linenumbers1 = set(lineno for (index, lineno) + in findlinestarts(code)) + linenumbers2 = set(lineno for (index, lineno) + in findlinestarts(execcode)) if linenumbers1 != linenumbers2: raise SyntaxError("doctest is not a single statement") @@ -1855,17 +1855,6 @@ def parallel_dispatch(self): """ opt = self.controller.options - job_client = None - try: - from gnumake_tokenpool import JobClient, NoJobServer - except ImportError: - pass - else: - try: - job_client = JobClient(use_cysignals=True) - except NoJobServer: - pass - source_iter = iter(self.controller.sources) # If timeout was 0, simply set a very long time @@ -1987,9 +1976,6 @@ def sel_exit(): w.copied_pid = w.pid w.close() finished.append(w) - if job_client: - job_client.release() - workers = new_workers # Similarly, process finished workers. @@ -2024,14 +2010,11 @@ def sel_exit(): break # Start new workers if possible - while (source_iter is not None and len(workers) < opt.nthreads - and (not job_client or job_client.acquire())): + while source_iter is not None and len(workers) < opt.nthreads: try: source = next(source_iter) except StopIteration: source_iter = None - if job_client: - job_client.release() else: # Start a new worker. import copy @@ -2108,8 +2091,6 @@ def sel_exit(): sleep(die_timeout) for w in workers: w.kill() - if job_client: - job_client.release() finally: os._exit(0) @@ -2403,7 +2384,7 @@ def save_result_output(self): try: self.result = self.result_queue.get(block=False) except Empty: - self.result = (0, DictAsObject({'err': 'noresult'})) + self.result = (0, DictAsObject(dict(err='noresult'))) del self.result_queue self.outtmpfile.seek(0) @@ -2601,8 +2582,8 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None, *, runner.basename = self.source.basename runner.filename = self.source.path N = options.file_iterations - results = DictAsObject({'walltime': [], 'cputime': [], - 'err': None, 'walltime_skips': 0}) + results = DictAsObject(dict(walltime=[], cputime=[], + err=None, walltime_skips=0)) # multiprocessing.Process instances don't run exit # functions, so we run the functions added by doctests @@ -2627,7 +2608,7 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None, *, except BaseException: exc_info = sys.exc_info() tb = "".join(traceback.format_exception(*exc_info)) - result = (0, DictAsObject({'err': exc_info[0], 'tb': tb})) + result = (0, DictAsObject(dict(err=exc_info[0], tb=tb))) if result_queue is not None: result_queue.put(result, False) diff --git a/src/sage/doctest/marked_output.py b/src/sage/doctest/marked_output.py index e2f08443ea7..c50aae5a283 100644 --- a/src/sage/doctest/marked_output.py +++ b/src/sage/doctest/marked_output.py @@ -1,6 +1,6 @@ # sage_setup: distribution = sagemath-repl """ -Helper for attaching tolerance information to strings +Helper for attaching metadata to doctest output. """ # **************************************************************************** @@ -24,6 +24,19 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +from typing import TypedDict + +from typing_extensions import NotRequired, Unpack + + +class MarkedOutputType(TypedDict): + random: NotRequired[bool] + rel_tol: NotRequired[float] + abs_tol: NotRequired[float] + tol: NotRequired[float] + bitness_32: NotRequired[str] + bitness_64: NotRequired[str] + class MarkedOutput(str): """ @@ -44,12 +57,15 @@ class MarkedOutput(str): sage: MarkedOutput("56 µs") '56 \xb5s' """ + random = False rel_tol = 0 abs_tol = 0 tol = 0 + bitness_32 = "" + bitness_64 = "" - def update(self, **kwds): + def update(self, **kwargs: Unpack[MarkedOutputType]): """ EXAMPLES:: @@ -62,7 +78,7 @@ def update(self, **kwds): sage: s.abs_tol 1.00000000000000e-7 """ - self.__dict__.update(kwds) + self.__dict__.update(kwargs) return self def __reduce__(self): @@ -83,6 +99,11 @@ def __reduce__(self): """ return make_marked_output, (str(self), self.__dict__) + def __eq__(self, value: object) -> bool: + if isinstance(value, MarkedOutput): + return str(self) == str(value) and self.__dict__ == value.__dict__ + return False + def make_marked_output(s, D): """ diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index e1d7edc271f..49c4eb98d43 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -32,6 +32,7 @@ # the License, or (at your option) any later version. # https://www.gnu.org/licenses/ # **************************************************************************** +from __future__ import annotations import collections.abc import doctest @@ -40,6 +41,7 @@ from collections import defaultdict from functools import reduce from re import Pattern +import sys from typing import Literal, Union, overload from sage.doctest.check_tolerance import ( @@ -80,6 +82,9 @@ r'\s*(#+|%+|r"+|"+|\.\.)\s*sage\.doctest: (.*)' ) +bitness_marker = re.compile('#.*(32|64)-bit') +bitness_value = 64 if sys.maxsize > (1 << 32) else 32 + @overload def parse_optional_tags(string: str) -> dict[str, Union[str, None]]: @@ -544,7 +549,7 @@ def update_optional_tags(line, tags=None, *, add_tags=None, remove_tags=None, fo return line -def parse_tolerance(source, want): +def parse_tolerance(source: str, want: str) -> str | MarkedOutput: r""" Return a version of ``want`` marked up with the tolerance tags specified in ``source``. @@ -578,7 +583,21 @@ def parse_tolerance(source, want): safe, literals, state = strip_string_literals(source) first_line = safe.split('\n', 1)[0] if '#' not in first_line: - return want + if "#" not in want: + return want + + want_32 = "" + want_64 = "" + for line in want.split("\n"): + bitness = bitness_marker.search(line) + if bitness: + if bitness.groups()[0] == "32": + want_32 += line[:bitness.start()] + "\n" + else: + want_64 += line[:bitness.start()] + "\n" + if want_32 == "" and want_64 == "": + return want + return MarkedOutput(want).update(bitness_32=want_32, bitness_64=want_64) comment = first_line[first_line.find('#') + 1:] comment = comment[comment.index('(') + 1: comment.rindex(')')] # strip_string_literals replaces comments @@ -829,7 +848,7 @@ def __ne__(self, other): """ return not (self == other) - def parse(self, string, *args): + def parse(self, string: str, name: str = "") -> list[str | doctest.Example]: r""" A Sage specialization of :class:`doctest.DocTestParser`. @@ -1015,8 +1034,8 @@ def parse(self, string, *args): string = find_python_continuation.sub(r"\1" + ellipsis_tag + r"\2", string) string = find_sage_prompt.sub(r"\1>>> sage: ", string) string = find_sage_continuation.sub(r"\1...", string) - res = doctest.DocTestParser.parse(self, string, *args) - filtered = [] + res = doctest.DocTestParser.parse(self, string, name) + filtered: list[str | doctest.Example] = [] persistent_optional_tags = self.file_optional_tags persistent_optional_tag_setter = None persistent_optional_tag_setter_index = None @@ -1225,7 +1244,7 @@ def human_readable(match): return '' return ansi_escape_sequence.subn(human_readable, string)[0] - def check_output(self, want, got, optionflags): + def check_output(self, want: str | MarkedOutput, got: str, optionflags: int) -> bool: r""" Check to see if the output matches the desired output. @@ -1365,6 +1384,10 @@ def check_output(self, want, got, optionflags): want, got = check_tolerance_real_domain(want, got) elif want.abs_tol: want, got = check_tolerance_complex_domain(want, got) + elif want.bitness_32 and bitness_value == 32: + want = want.bitness_32 + elif want.bitness_64 and bitness_value == 64: + want = want.bitness_64 except ToleranceExceededError: return False diff --git a/src/sage/doctest/parsing_test.py b/src/sage/doctest/parsing_test.py index 29632e4451c..690ce20ac47 100644 --- a/src/sage/doctest/parsing_test.py +++ b/src/sage/doctest/parsing_test.py @@ -1,8 +1,17 @@ # sage_setup: distribution = sagemath-repl +import doctest import sys +import textwrap import pytest -from sage.doctest.parsing import SageDocTestParser, parse_optional_tags + +from sage.doctest.marked_output import MarkedOutput +from sage.doctest.parsing import ( + SageDocTestParser, + SageOutputChecker, + bitness_value, + parse_optional_tags, +) onlyLinux = pytest.mark.skipif( sys.platform != "linux", @@ -77,3 +86,27 @@ def test_parse_known_bug_with_description_returns_empty(): parser = SageDocTestParser(("sage",)) parsed = parser.parse("sage: x = int('1'*4301) # known bug, #34506") assert parsed == ["", ""] + + +def test_parse_bitness(): + parser = SageDocTestParser(("sage",)) + input = textwrap.dedent( + """ + sage: sys.maxsize > (1 << 32) + True # 64-bit + False # 32-bit + """ + ) + parsed = parser.parse(input)[1] + assert isinstance(parsed, doctest.Example) + assert parsed.want == MarkedOutput("True # 64-bit\nFalse # 32-bit\n").update( + bitness_32="False \n", bitness_64="True \n" + ) + + +def test_check_output_bitness(): + checker = SageOutputChecker() + expected = MarkedOutput("True # 64-bit\nFalse # 32-bit\n").update( + bitness_32="False \n", bitness_64="True \n" + ) + assert checker.check_output(expected, str(bitness_value == 64) + " \n", 0) diff --git a/src/sage/doctest/sources.py b/src/sage/doctest/sources.py index ba6c05137b3..e18e38e9f9c 100644 --- a/src/sage/doctest/sources.py +++ b/src/sage/doctest/sources.py @@ -29,7 +29,6 @@ # **************************************************************************** import os -import sys import re import random import doctest @@ -59,8 +58,6 @@ code_block = re.compile(r"^(\s*)[.][.]\s*code-block\s*::.*$") whitespace = re.compile(r"\s*") -bitness_marker = re.compile('#.*(32|64)-bit') -bitness_value = '64' if sys.maxsize > (1 << 32) else '32' # For neutralizing doctests find_prompt = re.compile(r"^(\s*)(>>>|sage:)(.*)") @@ -308,7 +305,6 @@ def _create_doctests(self, namespace, tab_okay=None): if tab_okay is None: tab_okay = isinstance(self, TexSource) self._init() - self.line_shift = 0 self.parser = SageDocTestParser(self.options.optional, self.options.long, probed_tags=self.options.probe, @@ -336,19 +332,6 @@ def _create_doctests(self, namespace, tab_okay=None): self._process_doc(doctests, doc, namespace, start) unparsed_doc = False else: - bitness = bitness_marker.search(line) - if bitness: - if bitness.groups()[0] != bitness_value: - self.line_shift += 1 - continue - else: - line = line[:bitness.start()] + "\n" - if self.line_shift and (m := sagestart.match(line)): - # We insert empty doctest lines to make up for the removed lines - indent_and_prompt = m.group(1) - doc.extend([indent_and_prompt + "# inserted to compensate for removed conditional doctest output\n"] - * self.line_shift) - self.line_shift = 0 doc.append(line) unparsed_doc = True if not in_docstring and (not just_finished or self.start_finish_can_overlap): @@ -367,7 +350,6 @@ def _create_doctests(self, namespace, tab_okay=None): start = lineno doc = [] else: - self.line_shift = 0 start = lineno doc = [] # In ReST files we can end the file without decreasing the indentation level. diff --git a/src/sage/graphs/graph_decompositions/modular_decomposition.pyx b/src/sage/graphs/graph_decompositions/modular_decomposition.pyx index 3616f63259b..c69c30475ea 100644 --- a/src/sage/graphs/graph_decompositions/modular_decomposition.pyx +++ b/src/sage/graphs/graph_decompositions/modular_decomposition.pyx @@ -434,8 +434,8 @@ def gamma_classes(graph): Ensure that the returned vertex sets from some random graphs are modules:: - sage: from sage.graphs.graph_decompositions.modular_decomposition import test_gamma_modules - sage: test_gamma_modules(2, 10, 0.5) + sage: from sage.graphs.graph_decompositions.modular_decomposition import check_gamma_modules + sage: check_gamma_modules(2, 10, 0.5) """ from itertools import chain from sage.sets.disjoint_set import DisjointSet @@ -550,7 +550,7 @@ def habib_maurer_algorithm(graph, g_classes=None): ....: 11:[12,1], 12:[11,1], 13:[14,16,17,1], 14:[13,17,1], ....: 16:[13,17,1], 17:[13,14,16,18,1], 18:[17], 24:[5,4,3,1]} sage: g = Graph(d) - sage: test_modular_decomposition(habib_maurer_algorithm(g), g) + sage: check_modular_decomposition(habib_maurer_algorithm(g), g) True Tetrahedral Graph is Series:: @@ -706,7 +706,7 @@ def modular_decomposition(G, algorithm=None): # Below functions are implemented to test the modular decomposition tree # ============================================================================ # Function implemented for testing -def test_modular_decomposition(tree_root, graph): +def check_modular_decomposition(tree_root, graph): """ Test the input modular decomposition tree using recursion. @@ -722,21 +722,21 @@ def test_modular_decomposition(tree_root, graph): sage: from sage.graphs.graph_decompositions.modular_decomposition import * sage: g = graphs.HexahedralGraph() - sage: test_modular_decomposition(modular_decomposition(g), g) + sage: check_modular_decomposition(modular_decomposition(g), g) True """ if tree_root.node_type != NodeType.NORMAL: for module in tree_root.children: - if not test_module(module, graph): + if not check_module(module, graph): # test whether modules pass the defining # characteristics of modules return False - if not test_modular_decomposition(module, + if not check_modular_decomposition(module, graph.subgraph(get_vertices(module))): # recursively test the modular decomposition subtrees return False - if not test_maximal_modules(tree_root, graph): + if not check_maximal_modules(tree_root, graph): # test whether the mdoules are maximal in nature return False @@ -744,7 +744,7 @@ def test_modular_decomposition(tree_root, graph): # Function implemented for testing -def test_maximal_modules(tree_root, graph): +def check_maximal_modules(tree_root, graph): r""" Test the maximal nature of modules in a modular decomposition tree. @@ -772,7 +772,7 @@ def test_maximal_modules(tree_root, graph): sage: from sage.graphs.graph_decompositions.modular_decomposition import * sage: g = graphs.HexahedralGraph() - sage: test_maximal_modules(modular_decomposition(g), g) + sage: check_maximal_modules(modular_decomposition(g), g) True """ if tree_root.node_type != NodeType.NORMAL: @@ -947,7 +947,7 @@ def form_module(index, other_index, tree_root, graph): # Function implemented for testing -def test_module(module, graph): +def check_module(module, graph): """ Test whether input module is actually a module. @@ -964,9 +964,9 @@ def test_module(module, graph): sage: from sage.graphs.graph_decompositions.modular_decomposition import * sage: g = graphs.HexahedralGraph() sage: tree_root = modular_decomposition(g) - sage: test_module(tree_root, g) + sage: check_module(tree_root, g) True - sage: test_module(tree_root.children[0], g) + sage: check_module(tree_root.children[0], g) True """ # A single vertex is a module @@ -1253,7 +1253,7 @@ def relabel_tree(root, perm): # ============================================================================= @random_testing -def test_gamma_modules(trials, vertices, prob, verbose=False): +def check_gamma_modules(trials, vertices, prob, verbose=False): r""" Verify that the vertices of each gamma class of a random graph are modules of that graph. @@ -1272,7 +1272,7 @@ def test_gamma_modules(trials, vertices, prob, verbose=False): EXAMPLES:: sage: from sage.graphs.graph_decompositions.modular_decomposition import * - sage: test_gamma_modules(3, 7, 0.5) + sage: check_gamma_modules(3, 7, 0.5) """ from sage.graphs.generators.random import RandomGNP for _ in range(trials): @@ -1314,8 +1314,8 @@ def permute_decomposition(trials, algorithm, vertices, prob, verbose=False): print(random_perm) t1 = algorithm(g1) t2 = algorithm(g2) - assert test_modular_decomposition(t1, g1) - assert test_modular_decomposition(t2, g2) + assert check_modular_decomposition(t1, g1) + assert check_modular_decomposition(t2, g2) t1p = relabel_tree(t1, random_perm) assert equivalent_trees(t1p, t2) if verbose: diff --git a/src/sage/interfaces/sympy.py b/src/sage/interfaces/sympy.py index 5a380a86271..4754ec5258f 100644 --- a/src/sage/interfaces/sympy.py +++ b/src/sage/interfaces/sympy.py @@ -1237,14 +1237,14 @@ def check_expression(expr, var_symbols, only_from_sympy=False): assert e_sage == SR(e_sympy) -def test_all(): +def check_all(): """ Call some tests that were originally in SymPy. EXAMPLES:: - sage: from sage.interfaces.sympy import test_all - sage: test_all() + sage: from sage.interfaces.sympy import check_all + sage: check_all() """ def test_basics(): check_expression("x", "x") diff --git a/src/sage/libs/gap/test.py b/src/sage/libs/gap/test.py index 73dad049dc9..1e4c3bc0d75 100644 --- a/src/sage/libs/gap/test.py +++ b/src/sage/libs/gap/test.py @@ -6,7 +6,7 @@ from sage.misc.temporary_file import tmp_filename -def test_write_to_file(): +def check_write_to_file(): """ Test that libgap can write to files. @@ -14,8 +14,8 @@ def test_write_to_file(): EXAMPLES:: - sage: from sage.libs.gap.test import test_write_to_file - sage: test_write_to_file() + sage: from sage.libs.gap.test import check_write_to_file + sage: check_write_to_file() """ fname = tmp_filename() message = "Ceci n'est pas une groupe" diff --git a/src/sage/libs/gap/test_long.py b/src/sage/libs/gap/test_long.py index 262f3b00e28..824434fd504 100644 --- a/src/sage/libs/gap/test_long.py +++ b/src/sage/libs/gap/test_long.py @@ -6,24 +6,24 @@ from sage.libs.gap.libgap import libgap -def test_loop_1(): +def check_loop_1(): """ EXAMPLES:: - sage: from sage.libs.gap.test_long import test_loop_1 - sage: test_loop_1() # long time (up to 25s on sage.math, 2013) + sage: from sage.libs.gap.test_long import check_loop_1 + sage: check_loop_1() # long time (up to 25s on sage.math, 2013) """ libgap.collect() for i in range(10000): _ = libgap.CyclicGroup(2) -def test_loop_2(): +def check_loop_2(): """ EXAMPLES:: - sage: from sage.libs.gap.test_long import test_loop_2 - sage: test_loop_2() # long time (10s on sage.math, 2013) + sage: from sage.libs.gap.test_long import check_loop_2 + sage: check_loop_2() # long time (10s on sage.math, 2013) """ G = libgap.FreeGroup(2) a, b = G.GeneratorsOfGroup() @@ -38,12 +38,12 @@ def test_loop_2(): n = libgap.Order(H1) -def test_loop_3(): +def check_loop_3(): """ EXAMPLES:: - sage: from sage.libs.gap.test_long import test_loop_3 - sage: test_loop_3() # long time (31s on sage.math, 2013) + sage: from sage.libs.gap.test_long import check_loop_3 + sage: check_loop_3() # long time (31s on sage.math, 2013) """ G = libgap.FreeGroup(2) a, b = G.GeneratorsOfGroup() diff --git a/src/sage/misc/explain_pickle.py b/src/sage/misc/explain_pickle.py index 664a86cd5bc..bd378b35d8f 100644 --- a/src/sage/misc/explain_pickle.py +++ b/src/sage/misc/explain_pickle.py @@ -652,7 +652,7 @@ def APPEND(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(['a']) + sage: check_pickle(['a']) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 @@ -670,7 +670,7 @@ def APPEND(self): sage: v = [] sage: v.append(v) - sage: test_pickle(v) + sage: check_pickle(v) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 @@ -694,7 +694,7 @@ def APPENDS(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(['a', 'b']) + sage: check_pickle(['a', 'b']) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 @@ -716,7 +716,7 @@ def APPENDS(self): sage: v = [] sage: v.append(v) sage: v.append(v) - sage: test_pickle(v) + sage: check_pickle(v) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 @@ -748,7 +748,7 @@ def _APPENDS_helper(self, lst, slice): an exception, so we can tell that cPickle doesn't call it either):: sage: from sage.misc.explain_pickle import * - sage: test_pickle(TestAppendList((True,))) # indirect doctest + sage: check_pickle(TestAppendList((True,))) # indirect doctest 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestAppendList' 43: q BINPUT 0 @@ -776,7 +776,7 @@ def _APPENDS_helper(self, lst, slice): sage: v = TestAppendNonlist() sage: v.list = [False, None] - sage: test_pickle(v, verbose_eval=True) + sage: check_pickle(v, verbose_eval=True) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestAppendNonlist' 46: q BINPUT 0 @@ -814,7 +814,7 @@ def _APPENDS_helper(self, lst, slice): instead of once. If we set pedantic=True, then this is fixed. (We show only the changed parts of the output):: - sage: test_pickle(v, verbose_eval=True, pedantic=True) + sage: check_pickle(v, verbose_eval=True, pedantic=True) 0: \x80 PROTO 2 ... explain_pickle in_current_sage=True: @@ -862,7 +862,7 @@ def BINFLOAT(self, f): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(float(pi)) # needs sage.symbolic + sage: check_pickle(float(pi)) # needs sage.symbolic 0: \x80 PROTO 2 2: G BINFLOAT 3.141592653589793 11: . STOP @@ -879,7 +879,7 @@ def BINGET(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + BINPUT + 'x' + POP + BINGET + 'x' + '.') # py2 + sage: check_pickle(EMPTY_LIST + BINPUT + 'x' + POP + BINGET + 'x' + '.') # py2 0: ] EMPTY_LIST 1: q BINPUT 120 3: 0 POP @@ -897,7 +897,7 @@ def BININT(self, n): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(dumps(100000r, compress=False)) # py2 + sage: check_pickle(dumps(100000r, compress=False)) # py2 0: \x80 PROTO 2 2: J BININT 100000 7: . STOP @@ -913,7 +913,7 @@ def BININT1(self, n): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(dumps(100r, compress=False)) # py2 + sage: check_pickle(dumps(100r, compress=False)) # py2 0: \x80 PROTO 2 2: K BININT1 100 4: . STOP @@ -929,7 +929,7 @@ def BININT2(self, n): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(dumps(1000r, compress=False)) # py2 + sage: check_pickle(dumps(1000r, compress=False)) # py2 0: \x80 PROTO 2 2: M BININT2 1000 5: . STOP @@ -946,7 +946,7 @@ def BINPUT(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + BINPUT + 'x' + POP + BINGET + 'x') # py2 + sage: check_pickle(EMPTY_LIST + BINPUT + 'x' + POP + BINGET + 'x') # py2 0: ] EMPTY_LIST 1: q BINPUT 120 3: 0 POP @@ -966,7 +966,7 @@ def BINSTRING(self, s): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle('T\5\0\0\0hello.') # py2 + sage: check_pickle('T\5\0\0\0hello.') # py2 0: T BINSTRING 'hello' 10: . STOP highest protocol among opcodes = 1 @@ -981,7 +981,7 @@ def BINUNICODE(self, s): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(u'hi\u1234\U00012345') # py2 + sage: check_pickle(u'hi\u1234\U00012345') # py2 0: \x80 PROTO 2 2: X BINUNICODE u'hi\u1234\U00012345' 16: q BINPUT 1 @@ -998,7 +998,7 @@ def BUILD(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(TestBuild()) + sage: check_pickle(TestBuild()) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestBuild' 38: q BINPUT 0 @@ -1037,7 +1037,7 @@ def BUILD(self): :: - sage: test_pickle(TestBuildSetstate(), verbose_eval=True) + sage: check_pickle(TestBuildSetstate(), verbose_eval=True) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestBuildSetstate' 46: q BINPUT 0 @@ -1130,7 +1130,7 @@ def DICT(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(DICT, args=('mark', 'a', 1, 2, 'b')) # py2 + sage: check_pickle(DICT, args=('mark', 'a', 1, 2, 'b')) # py2 0: ( MARK 1: P PERSID '1' 4: P PERSID '2' @@ -1153,7 +1153,7 @@ def DUP(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + DUP + TUPLE2 + STOP) # py2 + sage: check_pickle(EMPTY_LIST + DUP + TUPLE2 + STOP) # py2 0: ] EMPTY_LIST 1: 2 DUP 2: \x86 TUPLE2 @@ -1174,7 +1174,7 @@ def EMPTY_DICT(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_DICT) # py2 + sage: check_pickle(EMPTY_DICT) # py2 0: } EMPTY_DICT 1: . STOP highest protocol among opcodes = 1 @@ -1190,7 +1190,7 @@ def EMPTY_LIST(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST) # py2 + sage: check_pickle(EMPTY_LIST) # py2 0: ] EMPTY_LIST 1: . STOP highest protocol among opcodes = 1 @@ -1206,7 +1206,7 @@ def EMPTY_TUPLE(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_TUPLE) # py2 + sage: check_pickle(EMPTY_TUPLE) # py2 0: ) EMPTY_TUPLE 1: . STOP highest protocol among opcodes = 1 @@ -1223,7 +1223,7 @@ def EXT1(self, n): sage: from copyreg import * sage: from sage.misc.explain_pickle import * sage: add_extension('sage.misc.explain_pickle', 'EmptyNewstyleClass', 42) - sage: test_pickle(EmptyNewstyleClass()) + sage: check_pickle(EmptyNewstyleClass()) 0: \x80 PROTO 2 2: \x82 EXT1 42 4: ) EMPTY_TUPLE @@ -1245,7 +1245,7 @@ def EXT2(self, n): sage: from copyreg import * sage: from sage.misc.explain_pickle import * sage: add_extension('sage.misc.explain_pickle', 'EmptyNewstyleClass', 31415) - sage: test_pickle(EmptyNewstyleClass()) + sage: check_pickle(EmptyNewstyleClass()) 0: \x80 PROTO 2 2: \x83 EXT2 31415 5: ) EMPTY_TUPLE @@ -1267,7 +1267,7 @@ def EXT4(self, n): sage: from copyreg import * sage: from sage.misc.explain_pickle import * sage: add_extension('sage.misc.explain_pickle', 'EmptyNewstyleClass', 27182818) - sage: test_pickle(EmptyNewstyleClass()) + sage: check_pickle(EmptyNewstyleClass()) 0: \x80 PROTO 2 2: \x84 EXT4 27182818 7: ) EMPTY_TUPLE @@ -1288,7 +1288,7 @@ def FLOAT(self, f): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(FLOAT + '2.71828\n') # py2 + sage: check_pickle(FLOAT + '2.71828\n') # py2 0: F FLOAT 2.71828 9: . STOP highest protocol among opcodes = 0 @@ -1304,7 +1304,7 @@ def GET(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + PUT + '1\n' + POP + GET + '1\n' + '.') # py2 + sage: check_pickle(EMPTY_LIST + PUT + '1\n' + POP + GET + '1\n' + '.') # py2 0: ] EMPTY_LIST 1: p PUT 1 4: 0 POP @@ -1328,7 +1328,7 @@ def GLOBAL(self, name): :: - sage: test_pickle(TestGlobalOldName()) + sage: check_pickle(TestGlobalOldName()) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestGlobalOldName' 46: q BINPUT 0 @@ -1356,7 +1356,7 @@ def GLOBAL(self, name): A class name need not be a valid identifier:: sage: sage.misc.explain_pickle.__dict__['funny$name'] = TestGlobalFunnyName # see comment at end of file - sage: test_pickle((TestGlobalFunnyName(), TestGlobalFunnyName())) + sage: check_pickle((TestGlobalFunnyName(), TestGlobalFunnyName())) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle TestGlobalFunnyName' 48: q BINPUT 0 @@ -1435,7 +1435,7 @@ def INST(self, name): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps(EmptyOldstyleClass(), protocol=0)) # py2 + sage: check_pickle(pickle.dumps(EmptyOldstyleClass(), protocol=0)) # py2 0: ( MARK 1: i INST 'sage.misc.explain_pickle EmptyOldstyleClass' (MARK at 0) 46: p PUT 0 @@ -1468,7 +1468,7 @@ def INT(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(INT + "-12345\n") # py2 + sage: check_pickle(INT + "-12345\n") # py2 0: I INT -12345 8: . STOP highest protocol among opcodes = 0 @@ -1478,14 +1478,14 @@ def INT(self, n): INT can also be used to record True and False:: - sage: test_pickle(INT + "00\n") # py2 + sage: check_pickle(INT + "00\n") # py2 0: I INT False 4: . STOP highest protocol among opcodes = 0 explain_pickle in_current_sage=True/False: False result: False - sage: test_pickle(INT + "01\n") # py2 + sage: check_pickle(INT + "01\n") # py2 0: I INT True 4: . STOP highest protocol among opcodes = 0 @@ -1501,7 +1501,7 @@ def LIST(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(MARK + NONE + NEWFALSE + LIST) # py2 + sage: check_pickle(MARK + NONE + NEWFALSE + LIST) # py2 0: ( MARK 1: N NONE 2: \x89 NEWFALSE @@ -1521,7 +1521,7 @@ def LONG(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(LONG + "12345678909876543210123456789L\n") # py2 + sage: check_pickle(LONG + "12345678909876543210123456789L\n") # py2 0: L LONG 12345678909876543210123456789L 32: . STOP highest protocol among opcodes = 0 @@ -1536,7 +1536,7 @@ def LONG1(self, n): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(1L) # py2 + sage: check_pickle(1L) # py2 0: \x80 PROTO 2 2: \x8a LONG1 1L 5: . STOP @@ -1553,7 +1553,7 @@ def LONG4(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(LONG4 + '\014\0\0\0' + 'hello, world') # py2 + sage: check_pickle(LONG4 + '\014\0\0\0' + 'hello, world') # py2 0: \x8b LONG4 31079605376604435891501163880L 17: . STOP highest protocol among opcodes = 2 @@ -1569,7 +1569,7 @@ def LONG_BINGET(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + LONG_BINPUT + 'Sage' + POP + LONG_BINGET + 'Sage') # py2 + sage: check_pickle(EMPTY_LIST + LONG_BINPUT + 'Sage' + POP + LONG_BINGET + 'Sage') # py2 0: ] EMPTY_LIST 1: r LONG_BINPUT 1701273939 6: 0 POP @@ -1588,7 +1588,7 @@ def LONG_BINPUT(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + LONG_BINPUT + 'Sage' + POP + LONG_BINGET + 'Sage') # py2 + sage: check_pickle(EMPTY_LIST + LONG_BINPUT + 'Sage' + POP + LONG_BINGET + 'Sage') # py2 0: ] EMPTY_LIST 1: r LONG_BINPUT 1701273939 6: 0 POP @@ -1609,7 +1609,7 @@ def MARK(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(MARK + TUPLE) # py2 + sage: check_pickle(MARK + TUPLE) # py2 0: ( MARK 1: t TUPLE (MARK at 0) 2: . STOP @@ -1626,7 +1626,7 @@ def NEWFALSE(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(NEWFALSE) # py2 + sage: check_pickle(NEWFALSE) # py2 0: \x89 NEWFALSE 1: . STOP highest protocol among opcodes = 2 @@ -1642,7 +1642,7 @@ def NEWTRUE(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(NEWTRUE) # py2 + sage: check_pickle(NEWTRUE) # py2 0: \x88 NEWTRUE 1: . STOP highest protocol among opcodes = 2 @@ -1657,7 +1657,7 @@ def NEWOBJ(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(EmptyNewstyleClass()) + sage: check_pickle(EmptyNewstyleClass()) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle EmptyNewstyleClass' 47: q BINPUT 0 @@ -1688,7 +1688,7 @@ def NONE(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(NONE) # py2 + sage: check_pickle(NONE) # py2 0: N NONE 1: . STOP highest protocol among opcodes = 0 @@ -1703,7 +1703,7 @@ def OBJ(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(EmptyOldstyleClass()) + sage: check_pickle(EmptyOldstyleClass()) 0: \x80 PROTO 2 2: c GLOBAL 'sage.misc.explain_pickle EmptyOldstyleClass' 47: q BINPUT 0 @@ -1733,7 +1733,7 @@ def PERSID(self, id): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(PERSID + "0\n" + '.', args=('Yo!',)) # py2 + sage: check_pickle(PERSID + "0\n" + '.', args=('Yo!',)) # py2 0: P PERSID '0' 3: . STOP highest protocol among opcodes = 0 @@ -1749,7 +1749,7 @@ def BINPERSID(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(INT + "0\n" + BINPERSID + '.', args=('Yo!',)) # py2 + sage: check_pickle(INT + "0\n" + BINPERSID + '.', args=('Yo!',)) # py2 0: I INT 0 3: Q BINPERSID 4: . STOP @@ -1767,7 +1767,7 @@ def POP(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(INT + "0\n" + POP + INT + "42\n") # py2 + sage: check_pickle(INT + "0\n" + POP + INT + "42\n") # py2 0: I INT 0 3: 0 POP 4: I INT 42 @@ -1787,7 +1787,7 @@ def POP_MARK(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(MARK + NONE + NEWFALSE + POP_MARK + NEWTRUE) # py2 + sage: check_pickle(MARK + NONE + NEWFALSE + POP_MARK + NEWTRUE) # py2 0: ( MARK 1: N NONE 2: \x89 NEWFALSE @@ -1806,7 +1806,7 @@ def PROTO(self, proto): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(0r) # py2 + sage: check_pickle(0r) # py2 0: \x80 PROTO 2 2: K BININT1 0 4: . STOP @@ -1824,7 +1824,7 @@ def PUT(self, n): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_LIST + PUT + '1\n' + POP + GET + '1\n' + '.') # py2 + sage: check_pickle(EMPTY_LIST + PUT + '1\n' + POP + GET + '1\n' + '.') # py2 0: ] EMPTY_LIST 1: p PUT 1 4: 0 POP @@ -1845,7 +1845,7 @@ def REDUCE(self): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps(EmptyNewstyleClass(), protocol=1)) # py2 + sage: check_pickle(pickle.dumps(EmptyNewstyleClass(), protocol=1)) # py2 0: c GLOBAL 'copy_reg _reconstructor' 25: q BINPUT 0 27: ( MARK @@ -1874,7 +1874,7 @@ def REDUCE(self): :: - sage: test_pickle(TestReduceGetinitargs(), verbose_eval=True) # py2 + sage: check_pickle(TestReduceGetinitargs(), verbose_eval=True) # py2 Running __init__ for TestReduceGetinitargs 0: \x80 PROTO 2 2: ( MARK @@ -1905,7 +1905,7 @@ def REDUCE(self): :: - sage: test_pickle(TestReduceNoGetinitargs(), verbose_eval=True) # py2 + sage: check_pickle(TestReduceNoGetinitargs(), verbose_eval=True) # py2 Running __init__ for TestReduceNoGetinitargs 0: \x80 PROTO 2 2: ( MARK @@ -1977,7 +1977,7 @@ def SETITEM(self): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps({'a': 'b'})) # py2 + sage: check_pickle(pickle.dumps({'a': 'b'})) # py2 0: ( MARK 1: d DICT (MARK at 0) 2: p PUT 0 @@ -1998,7 +1998,7 @@ def SETITEM(self): sage: value_rec = dict() sage: value_rec['circular'] = value_rec - sage: test_pickle(pickle.dumps(value_rec)) # py2 + sage: check_pickle(pickle.dumps(value_rec)) # py2 0: ( MARK 1: d DICT (MARK at 0) 2: p PUT 0 @@ -2020,7 +2020,7 @@ def SETITEM(self): sage: key = EmptyNewstyleClass() sage: key.circular = key_rec sage: key_rec[key] = 'circular' - sage: test_pickle(pickle.dumps(key_rec)) # py2 + sage: check_pickle(pickle.dumps(key_rec)) # py2 0: ( MARK 1: d DICT (MARK at 0) 2: p PUT 0 @@ -2078,7 +2078,7 @@ def SETITEMS(self): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps({'a': 'b', 1r : 2r}, protocol=2)) # py2 + sage: check_pickle(pickle.dumps({'a': 'b', 1r : 2r}, protocol=2)) # py2 0: \x80 PROTO 2 2: } EMPTY_DICT 3: q BINPUT 0 @@ -2103,7 +2103,7 @@ def SETITEMS(self): sage: key = EmptyOldstyleClass() sage: key.recdict = recdict sage: recdict[key] = 'circular_key' - sage: test_pickle(pickle.dumps(recdict, protocol=2)) # py2 + sage: check_pickle(pickle.dumps(recdict, protocol=2)) # py2 0: \x80 PROTO 2 2: } EMPTY_DICT 3: q BINPUT 0 @@ -2156,7 +2156,7 @@ def _SETITEMS_helper(self, slice): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps({'a': 'b'})) # indirect doctest # py2 + sage: check_pickle(pickle.dumps({'a': 'b'})) # indirect doctest # py2 0: ( MARK 1: d DICT (MARK at 0) 2: p PUT 0 @@ -2196,7 +2196,7 @@ def SHORT_BINSTRING(self, s): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(dumps('hello', compress=False)) # py2 + sage: check_pickle(dumps('hello', compress=False)) # py2 0: \x80 PROTO 2 2: U SHORT_BINSTRING 'hello' 9: q BINPUT 1 @@ -2214,7 +2214,7 @@ def STOP(self): sage: from pickle import * sage: from sage.misc.explain_pickle import * - sage: test_pickle(EMPTY_TUPLE) # py2 + sage: check_pickle(EMPTY_TUPLE) # py2 0: ) EMPTY_TUPLE 1: . STOP highest protocol among opcodes = 1 @@ -2229,7 +2229,7 @@ def STRING(self, s): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle("S'Testing...'\n.") # py2 + sage: check_pickle("S'Testing...'\n.") # py2 0: S STRING 'Testing...' 14: . STOP highest protocol among opcodes = 0 @@ -2245,7 +2245,7 @@ def TUPLE(self): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps(('a',))) # py2 + sage: check_pickle(pickle.dumps(('a',))) # py2 0: ( MARK 1: S STRING 'a' 6: p PUT 0 @@ -2265,7 +2265,7 @@ def TUPLE(self): sage: v = ([],) sage: v[0].append(v) - sage: test_pickle(pickle.dumps(v)) # py2 + sage: check_pickle(pickle.dumps(v)) # py2 0: ( MARK 1: ( MARK 2: l LIST (MARK at 1) @@ -2295,7 +2295,7 @@ def TUPLE1(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(('a',)) + sage: check_pickle(('a',)) 0: \x80 PROTO 2 2: X BINUNICODE 'a' 8: q BINPUT 0 @@ -2315,7 +2315,7 @@ def TUPLE2(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(('a','b')) + sage: check_pickle(('a','b')) 0: \x80 PROTO 2 2: X BINUNICODE 'a' 8: q BINPUT 0 @@ -2338,7 +2338,7 @@ def TUPLE3(self): TESTS:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(('a','b','c')) + sage: check_pickle(('a','b','c')) 0: \x80 PROTO 2 2: X BINUNICODE 'a' 8: q BINPUT 0 @@ -2365,7 +2365,7 @@ def UNICODE(self, s): sage: import pickle sage: from sage.misc.explain_pickle import * - sage: test_pickle(pickle.dumps(u'hi\u1234\U00012345')) # py2 + sage: check_pickle(pickle.dumps(u'hi\u1234\U00012345')) # py2 0: V UNICODE u'hi\u1234\U00012345' 20: p PUT 0 23: . STOP @@ -2545,7 +2545,7 @@ def unpickle_appends(lst, vals): append(v) -def test_pickle(p, verbose_eval=False, pedantic=False, args=()): +def check_pickle(p, verbose_eval=False, pedantic=False, args=()): r""" Test :func:`explain_pickle` on a given pickle ``p``. @@ -2555,18 +2555,18 @@ def test_pickle(p, verbose_eval=False, pedantic=False, args=()): with a '.') - a string containing a pickle fragment (not ending with '.') - test_pickle will synthesize a pickle that will push args onto + check_pickle will synthesize a pickle that will push args onto the stack (using persistent IDs), run the pickle fragment, and then STOP (if the string 'mark' occurs in args, then a mark will be pushed) - - an arbitrary object; :func:`test_pickle` will pickle the object + - an arbitrary object; :func:`check_pickle` will pickle the object - Once it has a pickle, :func:`test_pickle` will print the pickle's + Once it has a pickle, :func:`check_pickle` will print the pickle's disassembly, run :func:`explain_pickle` with ``in_current_sage=True`` and ``False``, print the results, evaluate the results, unpickle the object with cPickle, and compare all three results. - If ``verbose_eval`` is ``True``, then :func:`test_pickle` will print messages + If ``verbose_eval`` is ``True``, then :func:`check_pickle` will print messages before evaluating the pickles; this is to allow for tests where the unpickling prints messages (to verify that the same operations occur in all cases). @@ -2574,7 +2574,7 @@ def test_pickle(p, verbose_eval=False, pedantic=False, args=()): EXAMPLES:: sage: from sage.misc.explain_pickle import * - sage: test_pickle(['a']) + sage: check_pickle(['a']) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 diff --git a/src/sage/misc/random_testing.py b/src/sage/misc/random_testing.py index bda8cee6ba6..1a881a7c6e4 100644 --- a/src/sage/misc/random_testing.py +++ b/src/sage/misc/random_testing.py @@ -67,7 +67,7 @@ def random_testing(fn): debugging the problem. With the former snippet, you only need to rerun ``test_foo(100)`` with a known-failing random seed. - See :func:`sage.misc.random_testing.test_add_commutes` for a + See :func:`sage.misc.random_testing.check_add_commutes` for a simple example using this decorator, and :mod:`sage.rings.tests` for realistic uses. @@ -160,7 +160,7 @@ def wrapped_fun(*args, **kwargs): @random_testing -def test_add_commutes(trials, verbose=False): +def check_add_commutes(trials, verbose=False): r""" This is a simple demonstration of the :func:`random_testing` decorator and its recommended usage. @@ -169,14 +169,14 @@ def test_add_commutes(trials, verbose=False): EXAMPLES:: - sage: from sage.misc.random_testing import test_add_commutes - sage: test_add_commutes(2, verbose=True, seed=0) + sage: from sage.misc.random_testing import check_add_commutes + sage: check_add_commutes(2, verbose=True, seed=0) a == -4, b == 0 ... Passes! a == -1/2, b == -1/95 ... Passes! - sage: test_add_commutes(10) - sage: test_add_commutes(1000) # long time + sage: check_add_commutes(10) + sage: check_add_commutes(1000) # long time """ from sage.rings.rational_field import QQ for _ in range(trials): @@ -190,14 +190,14 @@ def test_add_commutes(trials, verbose=False): @random_testing -def test_add_is_mul(trials, verbose=False): +def check_add_is_mul(trials, verbose=False): r""" This example demonstrates a failing :func:`random_testing` test, and shows how to reproduce the error. DO NOT USE THIS AS AN EXAMPLE OF HOW TO USE :func:`random_testing`! Instead, look at - :func:`sage.misc.random_testing.test_add_commutes`. + :func:`sage.misc.random_testing.check_add_commutes`. We test that ``a+b == a*b``, for *a*, *b* rational. This is of course false, so the test will almost always fail. diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index 70208389fa4..a0605fa19f0 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -1767,7 +1767,7 @@ def _gap_init_(self) -> str: minus_infinity = InfinityRing.gen(1) -def test_comparison(ring): +def check_comparison(ring): """ Check comparison with infinity. @@ -1783,17 +1783,17 @@ def test_comparison(ring): EXAMPLES:: - sage: from sage.rings.infinity import test_comparison + sage: from sage.rings.infinity import check_comparison sage: rings = [ZZ, QQ, RDF] sage: rings += [RR, RealField(200)] # needs sage.rings.real_mpfr sage: rings += [RLF, RIF] # needs sage.rings.real_interval_field sage: for R in rings: ....: print('testing {}'.format(R)) - ....: test_comparison(R) + ....: check_comparison(R) testing Integer Ring testing Rational Field testing Real Double Field... - sage: test_comparison(AA) # needs sage.rings.number_field + sage: check_comparison(AA) # needs sage.rings.number_field Comparison with number fields does not work:: @@ -1806,7 +1806,7 @@ def test_comparison(ring): ``False`` (meaning: cannot decide) already for some very elementary comparisons:: - sage: test_comparison(SR) # known bug # needs sage.symbolic + sage: check_comparison(SR) # known bug # needs sage.symbolic Traceback (most recent call last): ... AssertionError: testing -1000.0 in Symbolic Ring: id = ... @@ -1838,7 +1838,7 @@ def test_comparison(ring): assert infinity >= z, msg -def test_signed_infinity(pos_inf): +def check_signed_infinity(pos_inf): """ Test consistency of infinity representations. diff --git a/src/sage/rings/number_field/number_field_morphisms.pyx b/src/sage/rings/number_field/number_field_morphisms.pyx index 5d075f5f87f..d24aef70fc2 100644 --- a/src/sage/rings/number_field/number_field_morphisms.pyx +++ b/src/sage/rings/number_field/number_field_morphisms.pyx @@ -492,10 +492,10 @@ def root_from_approx(f, a): return LazyAlgebraic(CLF, f, a, prec=0) # p-adic lazy, when implemented, would go here else: - from sage.symbolic.relation import test_relation_maxima + from sage.symbolic.relation import check_relation_maxima rel = (f(a) != 0) if (rel is True - or (not isinstance(rel, bool) and test_relation_maxima(rel))): + or (not isinstance(rel, bool) and check_relation_maxima(rel))): raise ValueError("{} is not a root of {}".format(a, f)) return a diff --git a/src/sage/rings/tests.py b/src/sage/rings/tests.py index 43eea1bd452..ea5fe2ede53 100644 --- a/src/sage/rings/tests.py +++ b/src/sage/rings/tests.py @@ -333,14 +333,14 @@ def random_rings(level=MAX_LEVEL): @random_testing -def test_random_elements(level=MAX_LEVEL, trials=1): +def check_random_elements(level=MAX_LEVEL, trials=1): """ Create random elements of random rings until a crash occurs, in which case an exception is raised. Defaults to running a single trial, but more can be specified. To run tests in an infinite loop, you could use:: - while True: test_random_elements(trials=100, print_seed=True) + while True: check_random_elements(trials=100, print_seed=True) INPUT: @@ -352,7 +352,7 @@ def test_random_elements(level=MAX_LEVEL, trials=1): EXAMPLES:: sage: import sage.rings.tests - sage: sage.rings.tests.test_random_elements(trials=2, seed=0) # needs sage.rings.number_field + sage: sage.rings.tests.check_random_elements(trials=2, seed=0) # needs sage.rings.number_field survived 0 tests Rational Field -1/2 @@ -363,9 +363,9 @@ def test_random_elements(level=MAX_LEVEL, trials=1): ---- sage: # needs sage.rings.finite_rings sage.rings.number_field sage.rings.padics - sage: sage.rings.tests.test_random_elements(trials=10) + sage: sage.rings.tests.check_random_elements(trials=10) survived 0 tests... - sage: sage.rings.tests.test_random_elements(trials=1000) # long time (5 seconds) + sage: sage.rings.tests.check_random_elements(trials=1000) # long time (5 seconds) survived 0 tests... """ r = random_rings(level) @@ -381,7 +381,7 @@ def test_random_elements(level=MAX_LEVEL, trials=1): @random_testing -def test_random_arith(level=MAX_LEVEL, trials=1): +def check_random_arith(level=MAX_LEVEL, trials=1): """ Create random elements of random rings and do some arithmetic with them. @@ -430,7 +430,7 @@ def test_random_arith(level=MAX_LEVEL, trials=1): @random_testing -def test_karatsuba_multiplication(base_ring, maxdeg1, maxdeg2, +def check_karatsuba_multiplication(base_ring, maxdeg1, maxdeg2, ref_mul=lambda f, g: f._mul_generic(g), base_ring_random_elt_args=[], numtests=10, verbose=False): diff --git a/src/sage/schemes/elliptic_curves/kraus.py b/src/sage/schemes/elliptic_curves/kraus.py index 5e749a0448d..062d89fc00d 100644 --- a/src/sage/schemes/elliptic_curves/kraus.py +++ b/src/sage/schemes/elliptic_curves/kraus.py @@ -232,7 +232,7 @@ def sqrt_mod_4(x, P): # Kraus test and check for primes dividing 3: -def test_b2_local(c4, c6, P, b2, debug=False): +def check_b2_local(c4, c6, P, b2, debug=False): r""" Test if `b_2` gives a valid model at a prime dividing 3. @@ -257,25 +257,25 @@ def test_b2_local(c4, c6, P, b2, debug=False): sage: c4 = -60544*a + 385796 sage: c6 = -55799680*a + 262126328 sage: P3a, P3b = K.primes_above(3) - sage: from sage.schemes.elliptic_curves.kraus import test_b2_local + sage: from sage.schemes.elliptic_curves.kraus import check_b2_local `b_2=0` works at the first prime but not the second:: sage: b2 = 0 - sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + sage: check_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (3784/3*a-96449/12)*x + (1743740/27*a-32765791/108) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + sage: check_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field False `b_2=-a` works at the second prime but not the first:: sage: b2 = -a # needs sage.rings.number_field - sage: test_b2_local(c4,c6,P3a,b2,debug=True) # needs sage.rings.number_field - test_b2_local: not integral at Fractional ideal (3, a + 1) + sage: check_b2_local(c4,c6,P3a,b2,debug=True) # needs sage.rings.number_field + check_b2_local: not integral at Fractional ideal (3, a + 1) False - sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + sage: check_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (-1/4*a)*x^2 + (3784/3*a-192893/24)*x + (56378369/864*a-32879311/108) over Number Field in a with defining polynomial x^2 - 10 @@ -284,11 +284,11 @@ def test_b2_local(c4, c6, P, b2, debug=False): sage: b2 = K.solve_CRT([0,-a],[P3a,P3b]); b2 # needs sage.rings.number_field a + 1 - sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + sage: check_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + sage: check_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 @@ -305,7 +305,7 @@ def test_b2_local(c4, c6, P, b2, debug=False): return E -def test_b2_global(c4, c6, b2, debug=False): +def check_b2_global(c4, c6, b2, debug=False): r""" Test if `b_2` gives a valid model at all primes dividing 3. @@ -329,16 +329,16 @@ def test_b2_global(c4, c6, b2, debug=False): sage: c4 = -60544*a + 385796 sage: c6 = -55799680*a + 262126328 sage: b2 = a+1 - sage: from sage.schemes.elliptic_curves.kraus import test_b2_global - sage: test_b2_global(c4,c6,b2) + sage: from sage.schemes.elliptic_curves.kraus import check_b2_global + sage: check_b2_global(c4,c6,b2) Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_global(c4,c6,0,debug=True) - test_b2_global: not integral at all primes dividing 3 + sage: check_b2_global(c4,c6,0,debug=True) + check_b2_global: not integral at all primes dividing 3 False - sage: test_b2_global(c4,c6,-a,debug=True) - test_b2_global: not integral at all primes dividing 3 + sage: check_b2_global(c4,c6,-a,debug=True) + check_b2_global: not integral at all primes dividing 3 False """ E = c4c6_model(c4,c6).rst_transform(b2/12,0,0) @@ -405,12 +405,12 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): if c4.valuation(P) == 0: b2 = (-c6*c4.inverse_mod(P3)).mod(P3) if debug: - assert test_b2_local(c4,c6,P,b2) + assert check_b2_local(c4,c6,P,b2) return True, b2 if c6.valuation(P) >= 3*e: b2 = c6.parent().zero() if debug: - assert test_b2_local(c4,c6,P,b2) + assert check_b2_local(c4,c6,P,b2) return True, b2 # check for a solution x to x^3-3*x*c4-26=0 (27), such an x must # also satisfy x*c4+c6=0 (3) and x^2=c4 (3) and x^3=-c6 (9), and @@ -420,14 +420,14 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): if (x*c4+c6).valuation(P) >= e: if (x*(x*x-3*c4)-2*c6).valuation(P) >= 3*e: if debug: - assert test_b2_local(c4,c6,P,x) + assert check_b2_local(c4,c6,P,x) return True, x return False, 0 # Kraus test and check for primes dividing 2: -def test_a1a3_local(c4, c6, P, a1, a3, debug=False): +def check_a1a3_local(c4, c6, P, a1, a3, debug=False): r""" Test if `a_1`, `a_3` are valid at a prime `P` dividing `2`. @@ -447,18 +447,18 @@ def test_a1a3_local(c4, c6, P, a1, a3, debug=False): EXAMPLES:: sage: # needs sage.rings.number_field - sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_local + sage: from sage.schemes.elliptic_curves.kraus import check_a1a3_local sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 sage: c6 = -55799680*a + 262126328 sage: P = K.primes_above(2)[0] - sage: test_a1a3_local(c4,c6,P,a,0) + sage: check_a1a3_local(c4,c6,P,a,0) Elliptic Curve defined by y^2 + a*x*y = x^3 + (3784/3*a-24106/3)*x + (1772120/27*a-2790758/9) over Number Field in a with defining polynomial x^2 - 10 - sage: test_a1a3_local(c4,c6,P,a,a,debug=True) - test_a1a3_local: not integral at Fractional ideal (2, a) + sage: check_a1a3_local(c4,c6,P,a,a,debug=True) + check_a1a3_local: not integral at Fractional ideal (2, a) False """ E = c4c6_model(c4,c6).rst_transform(a1**2/12,a1/2,a3/2) @@ -473,7 +473,7 @@ def test_a1a3_local(c4, c6, P, a1, a3, debug=False): return E -def test_a1a3_global(c4, c6, a1, a3, debug=False): +def check_a1a3_global(c4, c6, a1, a3, debug=False): r""" Test if `a_1`, `a_3` are valid at all primes `P` dividing 2. @@ -492,14 +492,14 @@ def test_a1a3_global(c4, c6, a1, a3, debug=False): EXAMPLES:: sage: # needs sage.rings.number_field - sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_global + sage: from sage.schemes.elliptic_curves.kraus import check_a1a3_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 sage: c6 = -55799680*a + 262126328 - sage: test_a1a3_global(c4,c6,a,a,debug=False) + sage: check_a1a3_global(c4,c6,a,a,debug=False) False - sage: test_a1a3_global(c4,c6,a,0) + sage: check_a1a3_global(c4,c6,a,0) Elliptic Curve defined by y^2 + a*x*y = x^3 + (3784/3*a-24106/3)*x + (1772120/27*a-2790758/9) over Number Field in a with defining polynomial x^2 - 10 @@ -517,7 +517,7 @@ def test_a1a3_global(c4, c6, a1, a3, debug=False): return E -def test_rst_global(c4, c6, r, s, t, debug=False): +def check_rst_global(c4, c6, r, s, t, debug=False): r""" Test if the `(r,s,t)`-transform of the standard `c_4,c_6`-model is integral. @@ -536,16 +536,16 @@ def test_rst_global(c4, c6, r, s, t, debug=False): EXAMPLES:: sage: # needs sage.rings.number_field - sage: from sage.schemes.elliptic_curves.kraus import test_rst_global + sage: from sage.schemes.elliptic_curves.kraus import check_rst_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2-10) sage: c4 = -60544*a + 385796 sage: c6 = -55799680*a + 262126328 - sage: test_rst_global(c4,c6,1/3*a - 133/6, 3/2*a, -89/2*a + 5) + sage: check_rst_global(c4,c6,1/3*a - 133/6, 3/2*a, -89/2*a + 5) Elliptic Curve defined by y^2 + 3*a*x*y + (-89*a+10)*y = x^3 + (a-89)*x^2 + (1202*a-5225)*x + (34881*a-151813) over Number Field in a with defining polynomial x^2 - 10 - sage: test_rst_global(c4,c6,a, 3, -89*a, debug=False) + sage: check_rst_global(c4,c6,a, 3, -89*a, debug=False) False """ E = c4c6_model(c4,c6).rst_transform(r,s,t) @@ -633,7 +633,7 @@ def check_Kraus_local_2(c4, c6, P, a1=None, assume_nonsingular=False): a1 = make_integral(c4/t,P,e) a13 = a1**3 a3 = make_integral((c6+a13**2)/(4*a13),P,2*e) - if test_a1a3_local(c4,c6,P,a1,a3): + if check_a1a3_local(c4,c6,P,a1,a3): return True, a1,a3 else: raise RuntimeError("check_Kraus_local_2 fails") @@ -643,7 +643,7 @@ def check_Kraus_local_2(c4, c6, P, a1=None, assume_nonsingular=False): a1 = c4.parent().zero() # 0 flag, a3 = sqrt_mod_4(c6/8,P) if flag: - if test_a1a3_local(c4,c6,P,a1,a3): + if check_a1a3_local(c4,c6,P,a1,a3): return True, a1,a3 else: raise RuntimeError("check_Kraus_local_2 fails") @@ -660,7 +660,7 @@ def check_Kraus_local_2(c4, c6, P, a1=None, assume_nonsingular=False): if flag: a1sq = a1*a1 if (4*a1sq*Px-(a1sq**2-c4)**2).valuation(P) >= 8*e: # (iii) - if test_a1a3_local(c4,c6,P,a1,a3): + if check_a1a3_local(c4,c6,P,a1,a3): return True, a1, a3 else: raise RuntimeError("check_Kraus_local_2 fails") @@ -731,14 +731,14 @@ def check_Kraus_local(c4, c6, P, assume_nonsingular=False): if K(2).valuation(P) > 0: flag, a1, a3 = check_Kraus_local_2(c4,c6,P,None,True) if flag: - E = test_a1a3_local(c4,c6,P,a1,a3) + E = check_a1a3_local(c4,c6,P,a1,a3) if E: return (True, E) return (False, None) if K(3).valuation(P) > 0: flag, b2 = check_Kraus_local_3(c4,c6,P,True) if flag: - E = test_b2_local(c4,c6,P,b2) + E = check_b2_local(c4,c6,P,b2) if E: return (True, E) return (False, None) @@ -832,7 +832,7 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): # test that this b2 value works at all P|3: if debug: - E = test_b2_global(c4,c6,b2) + E = check_b2_global(c4,c6,b2) if E: print("Using b2=%s gives a model integral at 3:\n%s" % (b2,E.ainvs())) else: @@ -868,7 +868,7 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): # test that these a1,a3 values work at all P|2: if debug: - E = test_a1a3_global(c4,c6,a1,a3,debug) + E = check_a1a3_global(c4,c6,a1,a3,debug) if E: print("Using (a1,a3)=(%s,%s) gives a model integral at 2:\n%s" % (a1,a3,E.ainvs())) else: @@ -900,7 +900,7 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): print("Using (r, s, t)=(%s, %s, %s) should give a global integral model..." % (r,s,t)) # Final computation of the curve E: - E = test_rst_global(c4,c6,r,s,t,debug) + E = check_rst_global(c4,c6,r,s,t,debug) if not E: if debug: print("Error in check_Kraus_global with combining mod-2 and mod-3 transforms") diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index ae97f236e94..5a53abc0652 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -3504,9 +3504,9 @@ cdef class Expression(Expression_abc): # associated with different semantics, different # precision, etc., that can lead to subtle bugs. Also, a # lot of basic Sage objects can't be put into maxima. - from sage.symbolic.relation import test_relation_maxima + from sage.symbolic.relation import check_relation_maxima if self.variables(): - return test_relation_maxima(self) + return check_relation_maxima(self) else: return False diff --git a/src/sage/symbolic/random_tests.py b/src/sage/symbolic/random_tests.py index 3291fe3cea0..795704a70ef 100644 --- a/src/sage/symbolic/random_tests.py +++ b/src/sage/symbolic/random_tests.py @@ -418,7 +418,7 @@ def incomparable(i, j): raise ValueError(msg) -def test_symbolic_expression_order(repetitions=100): +def check_symbolic_expression_order(repetitions=100): r""" Test whether the comparison of random symbolic expressions satisfies the strict weak order axioms. @@ -429,9 +429,9 @@ def test_symbolic_expression_order(repetitions=100): EXAMPLES:: - sage: from sage.symbolic.random_tests import test_symbolic_expression_order - sage: test_symbolic_expression_order(200) - sage: test_symbolic_expression_order(10000) # long time + sage: from sage.symbolic.random_tests import check_symbolic_expression_order + sage: check_symbolic_expression_order(200) + sage: check_symbolic_expression_order(10000) # long time """ rnd_length = 50 nvars = 10 diff --git a/src/sage/symbolic/relation.py b/src/sage/symbolic/relation.py index 01f5bd147e9..fa99457f2d9 100644 --- a/src/sage/symbolic/relation.py +++ b/src/sage/symbolic/relation.py @@ -360,65 +360,65 @@ import operator -def test_relation_maxima(relation): +def check_relation_maxima(relation): """ Return ``True`` if this (in)equality is definitely true. Return ``False`` if it is false or the algorithm for testing (in)equality is inconclusive. EXAMPLES:: - sage: from sage.symbolic.relation import test_relation_maxima + sage: from sage.symbolic.relation import check_relation_maxima sage: k = var('k') sage: pol = 1/(k-1) - 1/k -1/k/(k-1) - sage: test_relation_maxima(pol == 0) + sage: check_relation_maxima(pol == 0) True sage: f = sin(x)^2 + cos(x)^2 - 1 - sage: test_relation_maxima(f == 0) + sage: check_relation_maxima(f == 0) True - sage: test_relation_maxima( x == x ) + sage: check_relation_maxima( x == x ) True - sage: test_relation_maxima( x != x ) + sage: check_relation_maxima( x != x ) False - sage: test_relation_maxima( x > x ) + sage: check_relation_maxima( x > x ) False - sage: test_relation_maxima( x^2 > x ) + sage: check_relation_maxima( x^2 > x ) False - sage: test_relation_maxima( x + 2 > x ) + sage: check_relation_maxima( x + 2 > x ) True - sage: test_relation_maxima( x - 2 > x ) + sage: check_relation_maxima( x - 2 > x ) False Here are some examples involving assumptions:: sage: x, y, z = var('x, y, z') sage: assume(x>=y,y>=z,z>=x) - sage: test_relation_maxima(x==z) + sage: check_relation_maxima(x==z) True - sage: test_relation_maxima(zy) + sage: check_relation_maxima(z>y) False - sage: test_relation_maxima(y==z) + sage: check_relation_maxima(y==z) True sage: forget() sage: assume(x>=1,x<=1) - sage: test_relation_maxima(x==1) + sage: check_relation_maxima(x==1) True - sage: test_relation_maxima(x>1) + sage: check_relation_maxima(x>1) False - sage: test_relation_maxima(x>=1) + sage: check_relation_maxima(x>=1) True - sage: test_relation_maxima(x!=1) + sage: check_relation_maxima(x!=1) False sage: forget() sage: assume(x>0) - sage: test_relation_maxima(x==0) + sage: check_relation_maxima(x==0) False - sage: test_relation_maxima(x>-1) + sage: check_relation_maxima(x>-1) True - sage: test_relation_maxima(x!=0) + sage: check_relation_maxima(x!=0) True - sage: test_relation_maxima(x!=1) + sage: check_relation_maxima(x!=1) False sage: forget() @@ -433,7 +433,7 @@ def test_relation_maxima(relation): sage: f = log(x*y) - (log(x) + log(y)) sage: f(x=-1, y=i) -2*I*pi - sage: test_relation_maxima(f == 0) + sage: check_relation_maxima(f == 0) False sage: forget() @@ -442,7 +442,7 @@ def test_relation_maxima(relation): sage: assume(x, 'complex') sage: f = sqrt(x^2) - abs(x) - sage: test_relation_maxima(f == 0) + sage: check_relation_maxima(f == 0) False sage: forget() @@ -451,7 +451,7 @@ def test_relation_maxima(relation): sage: assume(x, 'real') sage: f1 = ( e^(I*x) - e^(-I*x) ) / ( I*e^(I*x) + I*e^(-I*x) ) sage: f2 = sin(x)/cos(x) - sage: test_relation_maxima(f1 - f2 == 0) + sage: check_relation_maxima(f1 - f2 == 0) True sage: forget() @@ -460,7 +460,7 @@ def test_relation_maxima(relation): sage: assume(x, 'complex') sage: f1 = ( e^(I*x) - e^(-I*x) ) / ( I*e^(I*x) + I*e^(-I*x) ) sage: f2 = sin(x)/cos(x) - sage: test_relation_maxima(f1 - f2 == 0) + sage: check_relation_maxima(f1 - f2 == 0) False sage: forget() @@ -471,7 +471,7 @@ def test_relation_maxima(relation): sage: assume(k, 'integer') sage: f1 = factorial(n+1)/factorial(n) sage: f2 = n + 1 - sage: test_relation_maxima(f1 - f2 == 0) + sage: check_relation_maxima(f1 - f2 == 0) True sage: forget() diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index 27c614d290f..6dc0d3e2e8e 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -57,7 +57,7 @@ import select -def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False, **kwds): +def check_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False, **kwds): r""" Run the program defined by ``args`` using the string ``input`` on the standard input. @@ -88,8 +88,8 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False EXAMPLES:: - sage: from sage.tests.cmdline import test_executable - sage: (out, err, ret) = test_executable(["cat"], "Hello World!") + sage: from sage.tests.cmdline import check_executable + sage: (out, err, ret) = check_executable(["cat"], "Hello World!") sage: out 'Hello World!' sage: err @@ -99,17 +99,17 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False We test the timeout option:: - sage: (out, err, ret) = test_executable(["sleep", "1"], timeout=0.1) + sage: (out, err, ret) = check_executable(["sleep", "1"], timeout=0.1) Traceback (most recent call last): ... - RuntimeError: timeout in test_executable() + RuntimeError: timeout in check_executable() TESTS: Run Sage itself with various options:: sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage"], pydebug_ignore_warnings=True) sage: out.find(version()) >= 0 True @@ -119,7 +119,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage"], "3^33\n", pydebug_ignore_warnings=True) sage: out.find(version()) >= 0 True @@ -131,7 +131,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "-q"], "3^33\n", pydebug_ignore_warnings=True) sage: out.find(version()) >= 0 False @@ -143,7 +143,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "-c", "print(3^33)"]) sage: print(out) 5559060566555523 @@ -153,7 +153,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "--min", "-c", "print(3^33)"]) sage: print(out) 5559060566555523 @@ -163,7 +163,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "--startuptime"]) sage: out.find("Slowest module import") >= 0 True @@ -174,7 +174,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Test help:: - sage: (out, err, ret) = test_executable(["sage", "-h"]) + sage: (out, err, ret) = check_executable(["sage", "-h"]) sage: out.find("evaluate cmd as sage") >= 0 True sage: err @@ -182,7 +182,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--help"]) + sage: (out, err, ret) = check_executable(["sage", "--help"]) sage: out.find("evaluate cmd as sage") >= 0 True sage: err @@ -190,7 +190,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--advanced"]) + sage: (out, err, ret) = check_executable(["sage", "--advanced"]) sage: out.find("run the Sage cleaner.") >= 0 True sage: err @@ -204,7 +204,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Basic information about the Sage installation:: - sage: (out, err, ret) = test_executable(["sage", "-v"]) + sage: (out, err, ret) = check_executable(["sage", "-v"]) sage: out.find(version()) >= 0 True sage: err @@ -213,7 +213,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # optional - sage_spkg - sage: (out, err, ret) = test_executable(["sage", "--root"]) + sage: (out, err, ret) = check_executable(["sage", "--root"]) sage: len(out) >= 2 True sage: err @@ -224,7 +224,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Test ``sage --info [packages]``:: sage: # optional - sage_spkg - sage: out, err, ret = test_executable(["sage", "--info", "sqlite"]) + sage: out, err, ret = check_executable(["sage", "--info", "sqlite"]) sage: print(out) sqlite... SQLite is a software library that implements a self-contained, @@ -243,8 +243,8 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False ....: fullname = os.path.join(dir, name) ....: with open(fullname, 'w') as F: ....: _ = F.write("print(3^33)\n") - ....: test_executable(["sage", fullname]) - ....: test_executable(["sage", name], cwd=dir) + ....: check_executable(["sage", fullname]) + ....: check_executable(["sage", name], cwd=dir) ('34\n', '', 0) ('34\n', '', 0) @@ -257,8 +257,8 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False ....: fullname = os.path.join(dir, name) ....: with open(fullname, 'w') as F: ....: _ = F.write("k. = GF(5^3); print(a^124)\n") - ....: test_executable(["sage", fullname]) - ....: test_executable(["sage", name], cwd=dir) + ....: check_executable(["sage", fullname]) + ....: check_executable(["sage", name], cwd=dir) ('1\n', '', 0) ('1\n', '', 0) @@ -276,8 +276,8 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False ....: _ = F.write("for i in range(5): s += i\n") ....: _ = F.write("sig_off()\n") ....: _ = F.write("print(Integer(s))") - ....: test_executable(["sage", fullname], pydebug_ignore_warnings=True) - ....: test_executable(["sage", name], cwd=dir, pydebug_ignore_warnings=True) + ....: check_executable(["sage", fullname], pydebug_ignore_warnings=True) + ....: check_executable(["sage", name], cwd=dir, pydebug_ignore_warnings=True) ('10\n', 'Compiling .../sage_test_file.spyx...\n', 0) ('10\n', 'Compiling sage_test_file.spyx...\n', 0) @@ -290,7 +290,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: F = open(script, 'w') sage: _ = F.write(s) sage: F.close() - sage: (out, err, ret) = test_executable(["sage", "--preparse", script]) + sage: (out, err, ret) = check_executable(["sage", "--preparse", script]) sage: ret 0 sage: os.path.isfile(script_py) @@ -299,13 +299,13 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Now test my_script.sage and the preparsed version my_script.sage.py:: sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "-t", "--optional=sage", script]) sage: ret 0 sage: out.find("All tests passed!") >= 0 True - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "-t", "--optional=sage", script_py]) sage: ret 0 @@ -328,7 +328,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: F = open(script, 'w') sage: _ = F.write(s) sage: F.close() - sage: (out, err, ret) = test_executable([ # long time + sage: (out, err, ret) = check_executable([ # long time ....: "sage", "-t", "--optional=sage", script]) sage: ret # long time 1 @@ -343,7 +343,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: F = open(script, 'w') sage: _ = F.write(s) sage: F.close() - sage: (out, err, ret) = test_executable([ # long time + sage: (out, err, ret) = check_executable([ # long time ....: "sage", "-t", "--optional=sage", "--debug", ....: "-p", "2", "--warn-long", "0", script], "help") sage: print(out) # long time @@ -392,11 +392,11 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False lengths to doctest the output.:: sage: test='r\"\"\"Add a doc-test for the fixdoctest command line option and, in particular, check that\n:issue:`10589` is fixed.\n\nEXAMPLES::\n\n sage: 1+1 # incorrect output\n 3\n sage: m=matrix(ZZ,3) # output when none is expected\n [0 0 0]\n [0 0 0]\n [1 0 0]\n sage: (2/3)*m # no output when it is expected\n sage: mu=PartitionTuple([[4,4],[3,3,2,1],[1,1]]) # output when none is expected\n [4, 4, 3, 3, 2, 1, 1]\n sage: mu.pp() # uneven indentation\n ****\n ****\n sage: PartitionTuples.options(convention="French")\n sage: mu.pp() # fix doctest with uneven indentation\n sage: PartitionTuples.options._reset()\n\"\"\"\n' - sage: test_file = os.path.join(tmp_dir(), 'test_file.py') + sage: check_file = os.path.join(tmp_dir(), 'test_file.py') sage: F = open(test_file, 'w') sage: _ = F.write(test) sage: F.close() - sage: (out, err, ret) = test_executable(["sage", "--fixdoctests", test_file]) # long time + sage: (out, err, ret) = check_executable(["sage", "--fixdoctests", check_file]) # long time sage: with open(test_file, 'r') as f: # long time ....: fixed_test = f.read() sage: import difflib # long time @@ -433,20 +433,20 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Test external programs being called by Sage:: - sage: (out, err, ret) = test_executable(["sage", "--sh"], "echo Hello World\nexit 42\n") + sage: (out, err, ret) = check_executable(["sage", "--sh"], "echo Hello World\nexit 42\n") sage: out.find("Hello World\n") >= 0 True sage: ret 42 - sage: (out, err, ret) = test_executable(["sage", "--sh", "-c", "echo Hello World; exit 42"]) + sage: (out, err, ret) = check_executable(["sage", "--sh", "-c", "echo Hello World; exit 42"]) sage: out.find("Hello World\n") >= 0 True sage: ret 42 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "--ipython"], "\n3**33\n", pydebug_ignore_warnings=True) sage: out.find("5559060566555523") >= 0 True @@ -455,7 +455,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--python"], "print(3^33)\n") + sage: (out, err, ret) = check_executable(["sage", "--python"], "print(3^33)\n") sage: out '34\n' sage: err @@ -463,7 +463,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--python3"], "print(3^33)\n") + sage: (out, err, ret) = check_executable(["sage", "--python3"], "print(3^33)\n") sage: out '34\n' sage: err @@ -471,7 +471,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--cython"]) + sage: (out, err, ret) = check_executable(["sage", "--cython"]) sage: print(err) ... cython: error: cython: Need at least one source file @@ -482,7 +482,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False ....: return True ....: except OSError: ....: return False - sage: (out, err, ret) = test_executable(["sage", "--ecl"], "(* 12345 54321)\n") + sage: (out, err, ret) = check_executable(["sage", "--ecl"], "(* 12345 54321)\n") sage: out.find("Embeddable Common-Lisp") >= 0 True sage: out.find("670592745") >= 0 @@ -492,7 +492,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--lisp"], "(* 12345 54321)\n") + sage: (out, err, ret) = check_executable(["sage", "--lisp"], "(* 12345 54321)\n") sage: out.find("Embeddable Common-Lisp") >= 0 True sage: out.find("670592745") >= 0 @@ -503,7 +503,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # long time - sage: (out, err, ret) = test_executable([ + sage: (out, err, ret) = check_executable([ ....: "sage", "--gap", "-q"], "Size(SymmetricGroup(5));\n") sage: out '120\n' @@ -512,14 +512,14 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable([ # long time # optional - gdb + sage: (out, err, ret) = check_executable([ # long time # optional - gdb ....: "sage", "--gdb"], 'quit\n') sage: out.find('(gdb) ') >= 0 # long time # optional - gdb True sage: ret # long time # optional - gdb 0 - sage: (out, err, ret) = test_executable(["sage", "--mwrank", "-v0", "-q"], "0 0 0 0 1\n") + sage: (out, err, ret) = check_executable(["sage", "--mwrank", "-v0", "-q"], "0 0 0 0 1\n") sage: out 'Curve [0,0,0,0,1] :\tRank = 0\n\n' sage: err @@ -527,7 +527,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--singular"], "12345*54321;\n") + sage: (out, err, ret) = check_executable(["sage", "--singular"], "12345*54321;\n") sage: out.find("A Computer Algebra System for Polynomial Computations") >= 0 True sage: out.find("670592745") >= 0 @@ -540,7 +540,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Test GP using the ``-f`` option which prevents the reading of a ``.gprc`` configuration file:: - sage: (out, err, ret) = test_executable(["sage", "--gp", "-f"], "3^33\nquit(42)\n") + sage: (out, err, ret) = check_executable(["sage", "--gp", "-f"], "3^33\nquit(42)\n") sage: out.find("PARI/GP") >= 0 True sage: out.find("5559060566555523") >= 0 @@ -552,7 +552,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Some programs of which we check functionality using only ``--version``:: - sage: (out, err, ret) = test_executable(["sage", "--maxima", "--version"]) + sage: (out, err, ret) = check_executable(["sage", "--maxima", "--version"]) sage: out.find("Maxima ") >= 0 True sage: err @@ -561,7 +561,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # optional - r - sage: (out, err, ret) = test_executable(["sage", "--R", "--version"]) + sage: (out, err, ret) = check_executable(["sage", "--R", "--version"]) sage: out.find("R version ") >= 0 True sage: err @@ -569,7 +569,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: ret 0 - sage: (out, err, ret) = test_executable(["sage", "--sqlite3", "--version"]) + sage: (out, err, ret) = check_executable(["sage", "--sqlite3", "--version"]) sage: out.startswith("3.") True sage: err @@ -580,7 +580,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Check some things requiring an internet connection:: sage: # optional - internet - sage: (out, err, ret) = test_executable(["sage", "--standard"]) + sage: (out, err, ret) = check_executable(["sage", "--standard"]) sage: out.find("cython") >= 0 True sage: err @@ -589,7 +589,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # optional - internet - sage: (out, err, ret) = test_executable(["sage", "--optional"]) + sage: (out, err, ret) = check_executable(["sage", "--optional"]) sage: out.find("database_cremona_ellcurve") >= 0 True sage: err @@ -598,7 +598,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False 0 sage: # optional - internet - sage: (out, err, ret) = test_executable(["sage", "--experimental"]) + sage: (out, err, ret) = check_executable(["sage", "--experimental"]) sage: out.find("valgrind") >= 0 True sage: err @@ -609,7 +609,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False Check an illegal command line option. This outputs an error to stdout, but we allow stderr in case this changes in the future:: - sage: (out, err, ret) = test_executable(["sage", "--zzfoobar"]) + sage: (out, err, ret) = check_executable(["sage", "--zzfoobar"]) sage: (out+err).find("unknown option: --zzfoobar") >= 0 True sage: ret > 0 @@ -622,7 +622,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: with open(input, 'w') as F: ....: _ = F.write(s) sage: L = ["sage", "--rst2ipynb", input] - sage: (out, err, ret) = test_executable(L) # optional - rst2ipynb + sage: (out, err, ret) = check_executable(L) # optional - rst2ipynb sage: err # optional - rst2ipynb '' sage: ret # optional - rst2ipynb @@ -644,7 +644,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: with open(input, 'w') as F: ....: _ = F.write(s) sage: L = ["sage", "--rst2ipynb", input, output] - sage: test_executable(L) # optional - rst2ipynb + sage: check_executable(L) # optional - rst2ipynb ('', '', 0) sage: import json # optional - rst2ipynb sage: d = json.load(open(output,'r')) # optional - rst2ipynb @@ -718,7 +718,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False sage: with open(input, 'w') as F: ....: _ = F.write(s) sage: L = ["sage", "--ipynb2rst", input, output] - sage: _ = test_executable(L) # long time # optional - pandoc + sage: _ = check_executable(L) # long time # optional - pandoc sage: print(open(output, 'r').read() == t) # long time # optional - pandoc # known bug #32697 True """ @@ -762,7 +762,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False if len(rlist) == 0: # Timeout! p.terminate() - raise RuntimeError("timeout in test_executable()") + raise RuntimeError("timeout in check_executable()") if fdout in rlist: s = p.stdout.read(1024) if not s: diff --git a/src/sage/tests/finite_poset.py b/src/sage/tests/finite_poset.py index 3d4cec06129..0773f6f58f2 100644 --- a/src/sage/tests/finite_poset.py +++ b/src/sage/tests/finite_poset.py @@ -92,21 +92,21 @@ sublattice_closed = ['distributive', 'modular', 'semidistributive', 'join_semidistributive', 'meet_semidistributive'] -def test_attrcall(name, L): +def check_attrcall(name, L): """ Return a function by name. - This is a helper function for test_finite_lattice(). This + This is a helper function for check_finite_lattice(). This will unify all Boolean-valued functions to a function without parameters. EXAMPLES:: - sage: from sage.tests.finite_poset import test_attrcall + sage: from sage.tests.finite_poset import check_attrcall sage: N5 = posets.PentagonPoset() - sage: N5.is_modular() == test_attrcall('is_modular', N5) + sage: N5.is_modular() == check_attrcall('is_modular', N5) True - sage: N5.is_constructible_by_doublings('convex') == test_attrcall('is_doubling_convex', N5) # needs sage.combinat + sage: N5.is_constructible_by_doublings('convex') == check_attrcall('is_doubling_convex', N5) # needs sage.combinat True """ if name == 'is_doubling_any': @@ -124,7 +124,7 @@ def test_attrcall(name, L): return attrcall(name)(L) -def test_finite_lattice(L): +def check_finite_lattice(L): """ Test several functions on a given finite lattice. @@ -147,9 +147,9 @@ def test_finite_lattice(L): EXAMPLES:: - sage: from sage.tests.finite_poset import test_finite_lattice + sage: from sage.tests.finite_poset import check_finite_lattice sage: L = posets.RandomLattice(10, 0.98) - sage: test_finite_lattice(L) is None # Long time + sage: check_finite_lattice(L) is None # Long time True """ from sage.combinat.posets.lattices import LatticePoset @@ -168,7 +168,7 @@ def test_finite_lattice(L): return None all_props = set(list(implications) + flatten(implications.values())) - P = {x: test_attrcall('is_' + x, L) for x in all_props} + P = {x: check_attrcall('is_' + x, L) for x in all_props} ### Relations between boolean-valued properties ### @@ -192,11 +192,11 @@ def test_finite_lattice(L): Ldual = L.dual() # Selfdual properties for p in selfdual_properties: - if P[p] != test_attrcall('is_'+p, Ldual): + if P[p] != check_attrcall('is_'+p, Ldual): raise ValueError("selfdual property %s error" % p) # Dual properties and elements for p1, p2 in dual_properties: - if P[p1] != test_attrcall('is_'+p2, Ldual): + if P[p1] != check_attrcall('is_'+p2, Ldual): raise ValueError("dual properties error %s" % p1) for e1, e2 in dual_elements: if set(attrcall(e1)(L)) != set(attrcall(e2)(Ldual)): @@ -397,7 +397,7 @@ def test_finite_lattice(L): # Sublattice-closed properties L_ = L.sublattice(Subsets(L).random_element()) for p in sublattice_closed: - if P[p] and not test_attrcall('is_'+p, L_): + if P[p] and not check_attrcall('is_'+p, L_): raise ValueError("property %s should apply to sublattices" % p) # Some sublattices @@ -444,7 +444,7 @@ def test_finite_lattice(L): raise ValueError("error in neutral_elements") -def test_finite_poset(P): +def check_finite_poset(P): """ Test several functions on a given finite poset. @@ -458,9 +458,9 @@ def test_finite_poset(P): EXAMPLES:: - sage: from sage.tests.finite_poset import test_finite_poset + sage: from sage.tests.finite_poset import check_finite_poset sage: P = posets.RandomPoset(10, 0.15) - sage: test_finite_poset(P) is None # Long time + sage: check_finite_poset(P) is None # Long time True """ from sage.combinat.posets.posets import Poset diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py index 52182fbe62d..95d971bec75 100644 --- a/src/sage/tests/memcheck/symbolic_expression.py +++ b/src/sage/tests/memcheck/symbolic_expression.py @@ -1,7 +1,7 @@ from sage.tests.memcheck.verify_no_leak import verify_no_leak -def test_sqrt_sqrt_2() -> None: +def check_sqrt_sqrt_2() -> None: from sage.misc.functional import sqrt T2 = sqrt(2)