details:   http://hg.sympy.org/sympy/rev/5bd07d1abb07
changeset: 1906:5bd07d1abb07
user:      Ondrej Certik <[EMAIL PROTECTED]>
date:      Tue Nov 18 17:07:53 2008 +0100
description:
Do not test examples if they are not installed

Previously, the examples directory was checked for code style. However, when
the user installs sympy using "./setup.py install", the examples are not
installed (at least not in the parent directory of "sympy"), so the result is
that sympy.test() fails.

Now we only check the examples dir if it's present.

diffs (67 lines):

diff -r 85d6378c55cc -r 5bd07d1abb07 sympy/utilities/tests/test_code_quality.py
--- a/sympy/utilities/tests/test_code_quality.py        Tue Nov 18 17:07:53 
2008 +0100
+++ b/sympy/utilities/tests/test_code_quality.py        Tue Nov 18 17:07:53 
2008 +0100
@@ -59,11 +59,27 @@
     path = split(__file__)[0]
     path = path + sep + pardir + sep + pardir # go to sympy/
     sympy_path = abspath(path)
+    assert exists(sympy_path)
+    check_directory_tree(sympy_path)
     examples_path = abspath(join(path + sep + pardir, "examples"))
-    paths = (sympy_path, examples_path)
-    for p in paths:
-        assert exists(p)
-        check_directory_tree(p)
+    # Remember that this test can be executed when examples are not installed
+    # (e.g. after "./setup.py install"), so don't raise an error if the
+    # examples are not found:
+    if exists(examples_path):
+        check_directory_tree(examples_path)
+
+def check_directory_tree_imports(p, exclude):
+    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()
 
 def test_implicit_imports():
     """
@@ -73,7 +89,6 @@
     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,
@@ -81,16 +96,10 @@
         "%(sep)smpmath%(sep)s" % sepd,
         "%(sep)splotting%(sep)s" % 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()
+    assert exists(sympy_path)
+    check_directory_tree_imports(sympy_path, exclude)
+    # Remember that this test can be executed when examples are not installed
+    # (e.g. after "./setup.py install"), so don't raise an error if the
+    # examples are not found:
+    if exists(examples_path):
+        check_directory_tree_imports(examples_path, exclude)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-commits" group.
To post to this group, send email to sympy-commits@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-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to