eric7/Project/ProjectSourcesBrowser.py

branch
unittest
changeset 9072
8d3ae97ee666
parent 9066
a219ade50f7c
child 9092
043848f65726
--- a/eric7/Project/ProjectSourcesBrowser.py	Tue May 17 17:23:07 2022 +0200
+++ b/eric7/Project/ProjectSourcesBrowser.py	Wed May 18 08:43:36 2022 +0200
@@ -755,19 +755,18 @@
         # a project coverage file
         fn = self.project.getMainScript(True)
         if fn is not None:
-            tfn = Utilities.getTestFileName(fn)
-            basename = os.path.splitext(fn)[0]
-            tbasename = os.path.splitext(tfn)[0]
-            prEnable = (
-                prEnable or
-                os.path.isfile("{0}.profile".format(basename)) or
-                os.path.isfile("{0}.profile".format(tbasename))
-            )
+            filenames = [os.path.splitext(f)[0]
+                         for f in [fn] + Utilities.getTestFileNames(fn)]
+            prEnable = any([
+                os.path.isfile("{0}.profile".format(f))
+                for f in filenames
+            ])
             coEnable = (
-                (coEnable or
-                 os.path.isfile("{0}.coverage".format(basename)) or
-                 os.path.isfile("{0}.coverage".format(tbasename))) and
-                self.project.isPy3Project()
+                self.project.isPy3Project() and
+                any([
+                    os.path.isfile("{0}.coverage".format(f))
+                    for f in filenames
+                ])
             )
         
         # now check the selected item
@@ -989,28 +988,18 @@
         files = []
         
         if pfn is not None:
-            tpfn = Utilities.getTestFileName(pfn)
-            basename = os.path.splitext(pfn)[0]
-            tbasename = os.path.splitext(tpfn)[0]
-            
-            f = "{0}.coverage".format(basename)
-            tf = "{0}.coverage".format(tbasename)
-            if os.path.isfile(f):
-                files.append(f)
-            if os.path.isfile(tf):
-                files.append(tf)
+            for filename in [pfn] + Utilities.getTestFileNames(pfn):
+                basename = os.path.splitext(filename)[0]
+                f = "{0}.coverage".format(basename)
+                if os.path.isfile(f):
+                    files.append(f)
         
         if fn is not None:
-            tfn = Utilities.getTestFileName(fn)
-            basename = os.path.splitext(fn)[0]
-            tbasename = os.path.splitext(tfn)[0]
-            
-            f = "{0}.coverage".format(basename)
-            tf = "{0}.coverage".format(tbasename)
-            if os.path.isfile(f) and f not in files:
-                files.append(f)
-            if os.path.isfile(tf) and tf not in files:
-                files.append(tf)
+            for filename in [fn] + Utilities.getTestFileNames(fn):
+                basename = os.path.splitext(filename)[0]
+                f = "{0}.coverage".format(basename)
+                if os.path.isfile(f):
+                    files.append(f)
         
         if files:
             if len(files) > 1:
@@ -1043,28 +1032,18 @@
         files = []
         
         if pfn is not None:
-            tpfn = Utilities.getTestFileName(pfn)
-            basename = os.path.splitext(pfn)[0]
-            tbasename = os.path.splitext(tpfn)[0]
-            
-            f = "{0}.profile".format(basename)
-            tf = "{0}.profile".format(tbasename)
-            if os.path.isfile(f):
-                files.append(f)
-            if os.path.isfile(tf):
-                files.append(tf)
+            for filename in [pfn] + Utilities.getTestFileNames(pfn):
+                basename = os.path.splitext(filename)[0]
+                f = "{0}.profile".format(basename)
+                if os.path.isfile(f):
+                    files.append(f)
         
         if fn is not None:
-            tfn = Utilities.getTestFileName(fn)
-            basename = os.path.splitext(fn)[0]
-            tbasename = os.path.splitext(tfn)[0]
-            
-            f = "{0}.profile".format(basename)
-            tf = "{0}.profile".format(tbasename)
-            if os.path.isfile(f) and f not in files:
-                files.append(f)
-            if os.path.isfile(tf) and tf not in files:
-                files.append(tf)
+            for filename in [fn] + Utilities.getTestFileNames(fn):
+                basename = os.path.splitext(filename)[0]
+                f = "{0}.profile".format(basename)
+                if os.path.isfile(f):
+                    files.append(f)
                 
         if files:
             if len(files) > 1:

eric ide

mercurial