2009/7/28 Vinzent Steinberg <vinzent.steinb...@googlemail.com>: > 2009/7/27 Ondrej Certik <ond...@certik.cz>: >> >> + else: >> + paths = [p for p in glob.glob('sympy/*/tests/test_*.py') >> + if any(a in p for a in args)] >> + t.add_paths(paths) >> >> ^^ Is this going to work for more nested tests, like >> sympy/core/assumptions/tests? >> >> If so, then +1. > > Yeah, it should, because '*' also matches '/'.
No, sadly '*' does not match '/'. I changed it to include sympy/*/tests/test_*.py and sympy/*/*/tests/test_*.py, this covers all tests currently in sympy. Is this sufficient? (This limitation does not apply for running the tests without arguments.) Vinzent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---
From 69d09f81790b85a8c70d0d56309890b44760515e Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg <vinzent.steinb...@gmail.com> Date: Mon, 27 Jul 2009 12:18:06 +0200 Subject: [PATCH] test: run all tests containing any of the given strings in their path This is much more powerful and user-friendly and allows things like bin/test core util which will test sympy/core/tests and sympy/utilities/tests. You can still use the old syntax. A limitation is that tests can't be nested deeper than 2 levels. --- sympy/utilities/runtests.py | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/sympy/utilities/runtests.py b/sympy/utilities/runtests.py index b60d85f..b3c29eb 100644 --- a/sympy/utilities/runtests.py +++ b/sympy/utilities/runtests.py @@ -53,27 +53,30 @@ def convert_to_native_paths(lst): """ return [os.path.join(*x.split("/")) for x in lst] -def test(*paths, **kwargs): +def test(*args, **kwargs): """ - Runs the tests specified by paths, or all tests if paths=[]. + Run all tests containing any of the given strings in their path. - Note: paths are specified relative to the sympy root directory in a unix - format (on all platforms including windows). + Warning: Tests nested deeper than 2 directories are not found if you + use strings to run only certain tests. Examples: - Run all tests: >> import sympy + + Run all tests: >> sympy.test() Run one file: - >> import sympy >> sympy.test("sympy/core/tests/test_basic.py") Run all tests in sympy/functions/ and some particular file: - >> import sympy >> sympy.test("sympy/core/tests/test_basic.py", "sympy/functions") + + Run all tests in sympy/core and sympy/utilities: + >> sympy.test("core", "util") """ + from glob import glob verbose = kwargs.get("verbose", False) tb = kwargs.get("tb", "short") kw = kwargs.get("kw", "") @@ -81,10 +84,14 @@ def test(*paths, **kwargs): colors = kwargs.get("colors", True) r = PyTestReporter(verbose, tb, colors) t = SymPyTests(r, kw, post_mortem) - if len(paths) > 0: - t.add_paths(paths) - else: + if len(args) == 0: t.add_paths(["sympy"]) + else: + paths = [p for p in glob('sympy/*/tests/test_*.py') + if any(a in p for a in args)] + paths += [p for p in glob('sympy/*/*/tests/test_*.py') + if any(a in p for a in args)] + t.add_paths(paths) return t.test() def doctest(*paths, **kwargs): -- 1.6.0.2