+1 I guess the patches got out of order since the last one took out all the exclusions. But anywho I like testing these things.
-- Andy On Thu, Nov 13, 2008 at 9:41 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote: > > Files that currently don't pass the tests are whitelisted. The goal is to not > use implicit imports, unless really necessary. > --- > sympy/utilities/tests/test_code_quality.py | 55 > ++++++++++++++++++++++++++++ > 1 files changed, 55 insertions(+), 0 deletions(-) > > diff --git a/sympy/utilities/tests/test_code_quality.py > b/sympy/utilities/tests/test_code_quality.py > index 6dea86c..1c7a413 100644 > --- a/sympy/utilities/tests/test_code_quality.py > +++ b/sympy/utilities/tests/test_code_quality.py > @@ -1,6 +1,7 @@ > from os import walk, sep, chdir, pardir > from os.path import split, join, abspath, exists > from glob import glob > +import re > > # System path separator (usually slash or backslash) > sepd = {"sep": sep} > @@ -14,6 +15,7 @@ EXCLUDE = set([ > > # Error messages > message_space = "File contains trailing whitespace: %s, line %s." > +message_implicit = "File contains an implicit import: %s, line %s." > message_tabs = "File contains tabs instead of spaces: %s, line %s." > message_carriage = "File contains carriage returns at end of line: %s, line > %s" > > @@ -62,3 +64,56 @@ def test_no_trailing_whitespace_and_no_tabs(): > for p in paths: > assert exists(p) > check_directory_tree(p) > + > +def test_implicit_imports(): > + """ > + Tests that all files except __init__.py use explicit imports. > + """ > + path = split(abspath(__file__))[0] > + path = path + sep + pardir + sep + pardir # go to sympy/ > + sympy_path = abspath(path) > + examples_path = abspath(join(path + sep + pardir, "examples")) > + paths = (sympy_path, examples_path) > + exclude = set([ > + "%(sep)sthirdparty%(sep)s" % sepd, > + "%(sep)s__init__.py" % sepd, > + # these two should be fixed: > + "%(sep)smpmath%(sep)s" % sepd, > + "%(sep)splotting%(sep)s" % sepd, > + > + # everything below should be fixed soon: > + "sympy/core/tests/test_evalf.py" % sepd, > + "sympy/functions/combinatorial/numbers.py" % sepd, > + "sympy/physics/tests/test_units.py" % sepd, > + "sympy/polynomials/factor_.py" % sepd, > + "sympy/polynomials/groebner_.py" % sepd, > + "sympy/polynomials/wrapper.py" % sepd, > + "sympy/polynomials/base.py" % sepd, > + "sympy/polynomials/div_.py" % sepd, > + "sympy/polynomials/roots_.py" % sepd, > + "sympy/polys/tests/test_polynomial.py" % sepd, > + "sympy/solvers/tests/test_solvers.py" % sepd, > + "sympy/statistics/distributions.py" % sepd, > + "sympy/examples/fem_test.py" % sepd, > + "sympy/examples/pidigits.py" % sepd, > + "sympy/examples/print_gtk.py" % sepd, > + "sympy/examples/print_pretty.py" % sepd, > + "sympy/examples/fem.py" % sepd, > + "sympy/examples/trees.py" % sepd, > + "sympy/galgebra/GAcalc.py" % sepd, > + "sympy/galgebra/GAsympy.py" % sepd, > + "sympy/galgebra/latex_out.py" % sepd, > + ]) > + for p in paths: > + assert exists(p) > + for root, dirs, files in walk(p): > + for fname in glob(join(root, "*.py")): > + if filter(lambda ex: ex in fname, exclude): > + continue > + file = open(fname, "r") > + try: > + for idx, line in enumerate(file): > + if re.match("^\s*from.*import.*\*",line): > + assert False, message_implicit % (fname, idx+1) > + finally: > + file.close() > -- > 1.5.6.5 > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---