Skip to content

Commit

Permalink
Clean-up testing: for foo.test.run_doctests, setting the __name__ usi…
Browse files Browse the repository at this point in the history
…ng foo.__name__ and changing default argument to print_info=False. This means that python/test.py does not need to define foo_doctester and can use foo.test.run_doctests on those.
  • Loading branch information
unhyperbolic committed Jul 27, 2024
1 parent 78a6ed6 commit f33a9b4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 37 deletions.
6 changes: 4 additions & 2 deletions python/exterior_to_link/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
simplify_to_base_tri,
put_in_S3,
main)
from . import __name__ as module_name

modules = [rational_linear_algebra,
pl_utils,
Expand All @@ -26,7 +27,7 @@
main]


def run_doctests(verbose=False, print_info=True):
def run_doctests(verbose=False, print_info=False):
globs = {'Manifold': snappy.Manifold,
'Triangulation': snappy.Triangulation}
results = snappy.testing.doctest_modules(modules,
Expand All @@ -35,9 +36,10 @@ def run_doctests(verbose=False, print_info=True):
print_info=print_info)
return results

run_doctests.__name__ = module_name

if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
verbose = len(optlist) > 0
results = run_doctests(verbose)
results = run_doctests(verbose, print_info=True)
sys.exit(results.failed)
3 changes: 1 addition & 2 deletions python/numeric_output_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,4 @@ def run_doctests(verbose=False):

return doctest.TestResults(failed, attempted)


run_doctests.__name__ = 'NumericOutputChecker'
run_doctests.__name__ = __name__
7 changes: 4 additions & 3 deletions python/snap/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..testing import doctest_modules
from ..pari import pari
import snappy
import snappy.snap as snap
from snappy import snap
import getopt
import sys

Expand Down Expand Up @@ -102,7 +102,7 @@ def big_test():
test_fields()


def run_doctests(verbose=False, print_info=True):
def run_doctests(verbose=False, print_info=False):
from snappy.snap.t3mlite import perm4
from snappy.snap.t3mlite import linalg
from snappy.snap.t3mlite import spun
Expand Down Expand Up @@ -144,8 +144,9 @@ def run_doctests(verbose=False, print_info=True):
return doctest_modules(modules, extraglobs=globs,
verbose=verbose, print_info=print_info)

run_doctests.__name__ = snap.__name__

if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
verbose = len(optlist) > 0
run_doctests(verbose)
run_doctests(verbose, print_info=True)
28 changes: 4 additions & 24 deletions python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from snappy.testing import (doctest_modules, cyopengl_works,
tk_root, root_is_fake, DocTestParser)
from snappy import numeric_output_checker
modules = []
modules = [snappy.exterior_to_link.test.run_doctests]

snappy.database.Manifold = snappy.SnapPy.Manifold

Expand All @@ -56,13 +56,6 @@
snappy.SnapPyHP.__test__.pop(key)


def snap_doctester(verbose):
return snappy.snap.test.run_doctests(verbose, print_info=False)


snap_doctester.__name__ = 'snappy.snap'


def snappy_database_doctester(verbose):
# snappy_manifolds's tests is still relying on
# SnapPy Number's _accuracy_for_testing.
Expand Down Expand Up @@ -106,7 +99,7 @@ def spherogram_doctester(verbose):
snappy.SnapPyHP,
snappy_database_doctester,
snappy,
snap_doctester,
snappy.snap.test.run_doctests,
snappy.matrix,
snappy.tiling.floor,
snappy.tiling.real_hash_dict,
Expand All @@ -126,24 +119,11 @@ def spherogram_doctester(verbose):
snappy.drilling,
snappy.drilling.test_cases,
snappy.ptolemy.test.run_doctests,
spherogram_doctester]
spherogram_doctester,
snappy.verify.test.run_doctests]

slow_modules = [ snappy.ptolemy.test.run_ptolemy_tests ]

def snappy_verify_doctester(verbose):
return snappy.verify.test.run_doctests(verbose, print_info=False)

snappy_verify_doctester.__name__ = 'snappy.verify'
modules.append(snappy_verify_doctester)

def snappy_exterior_to_link_doctester(verbose):
return snappy.exterior_to_link.test.run_doctests(verbose, print_info=False)


snappy_exterior_to_link_doctester.__name__ = 'snappy.exterior_to_link'
modules.insert(0, snappy_exterior_to_link_doctester)


def graphics_failures(verbose, windows, use_modernopengl):
if cyopengl_works():
print("Testing graphics ...")
Expand Down
15 changes: 9 additions & 6 deletions python/verify/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ def check_certified_intervals():
raise Exception


def generate_test_with_shapes_engine(module, engine):
def result(verbose):
def generate_test_with_shapes_engine(module, engine, print_info=False):
def result(verbose, print_info=print_info):
globs = {'Manifold':Manifold}

original = verify.CertifiedShapesEngine
verify.CertifiedShapesEngine = engine

r = doctest_modules([module], extraglobs=globs, verbose=verbose)
r = doctest_modules(
[module], extraglobs=globs, verbose=verbose, print_info=print_info)

verify.CertifiedShapesEngine = original

Expand All @@ -41,7 +42,7 @@ def result(verbose):
return result


def run_doctests(verbose=False, print_info=True):
def run_doctests(verbose=False, print_info=False):
globs = {'Manifold':Manifold}

return doctest_modules(
Expand Down Expand Up @@ -73,10 +74,12 @@ def run_doctests(verbose=False, print_info=True):
verify.square_extensions,
verify.real_algebra ],
extraglobs=globs,
verbose=verbose, print_info=print_info)
verbose=verbose,
print_info=print_info)

run_doctests.__name__ = verify.__name__

if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
verbose = len(optlist) > 0
run_doctests(verbose)
run_doctests(verbose, print_info=True)

0 comments on commit f33a9b4

Please sign in to comment.