Commits

Matěj Cepl committed 84507d5 Draft Merge

Merge pull request #39 from mcepl/fix_ImportUtilsTest

Make rope work with dynamically loaded modules elsewhere.

Comments (0)

Files changed (2)

rope/base/stdmods.py

 
 def _stdlib_path():
     import distutils.sysconfig
-    return distutils.sysconfig.get_python_lib(standard_lib=True)
+    return distutils.sysconfig.get_python_lib(standard_lib=True,
+                                              plat_specific=True)
+
 
 @utils.cached(1)
 def standard_modules():
     return python_modules() | dynload_modules()
 
+
 @utils.cached(1)
 def python_modules():
     result = set()
                     result.add(name[:-3])
     return result
 
+
 @utils.cached(1)
 def dynload_modules():
     result = set(sys.builtin_module_names)
         for name in os.listdir(dynload_path):
             path = os.path.join(dynload_path, name)
             if os.path.isfile(path):
-                if name.endswith('.so') or name.endswith('.dll'):
+                if name.endswith('.dll'):
                     result.add(os.path.splitext(name)[0])
+                if name.endswith('.so'):
+                    result.add(os.path.splitext(name)[0].replace('module', ''))
     return result

ropetest/builtinstest.py

         invalid = pymod['invalid'].get_object()
         self.assertTrue('sub' in invalid)
 
+    def test_time_in_std_mods(self):
+        import rope.base.stdmods
+        self.assertTrue('time' in rope.base.stdmods.standard_modules())
+
 
 def suite():
     result = unittest.TestSuite()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.