[pypy-svn] pypy default: Fix one test suite failure in test_import on Windows

amauryfa commits-noreply at bitbucket.org
Thu Mar 31 11:55:37 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r43040:558c510f7303
Date: 2011-03-31 11:30 +0200
http://bitbucket.org/pypy/pypy/changeset/558c510f7303/

Log:	Fix one test suite failure in test_import on Windows

diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -177,6 +177,14 @@
         import a
         assert a == a0
 
+    def test_trailing_slash(self):
+        import sys
+        try:
+            sys.path[0] += '/'
+            import a
+        finally:
+            sys.path[0] = sys.path[0].rstrip('/')
+
     def test_import_pkg(self):
         import sys
         import pkg

diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -84,7 +84,9 @@
 else:
     # XXX that's slow
     def case_ok(filename):
-        index = filename.rfind(os.sep)
+        index1 = filename.rfind(os.sep)
+        index2 = filename.rfind(os.altsep)
+        index = max(index1, index2)
         if index < 0:
             directory = os.curdir
         else:


More information about the Pypy-commit mailing list