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.
---
 sympy/utilities/tests/test_code_quality.py |   45 ++++++++++++++++-----------
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/sympy/utilities/tests/test_code_quality.py 
b/sympy/utilities/tests/test_code_quality.py
index 66accf7..b2f2e91 100644
--- a/sympy/utilities/tests/test_code_quality.py
+++ b/sympy/utilities/tests/test_code_quality.py
@@ -59,11 +59,27 @@ def test_no_trailing_whitespace_and_no_tabs():
     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 @@ def test_implicit_imports():
     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 @@ def test_implicit_imports():
         "%(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)
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to