Commits

Atamert Ölçgen  committed 19eb0af

Fixed error when COVERAGE_PATH_EXCLUDES is used

  • Participants
  • Parent commits 0c9b8b6

Comments (0)

Files changed (1)

File django_coverage/utils/module_tools/module_walker.py

             packages[m_name] = module
 
 def prune_dirs(root, dirs, exclude_dirs):
-    _dirs = [os.path.join(root, d) for d in dirs]
-    for i, p in enumerate(_dirs):
-        for e in exclude_dirs:
-            if re.search(e, p):
-                del dirs[i]
-                break
+    regexes = [re.compile(exclude_dir) for exclude_dir in exclude_dirs]
+    for path, dir_ in [(os.path.join(root, dir_), dir_) for dir_ in dirs]:
+        for regex in regexes:
+            if regex.search(path):
+                dirs.remove(dir_)
 
 def _get_all_packages(pkg_name, pkg, blacklist, exclude_dirs):
     packages = Packages().packages