Commits

Ned Batchelder  committed 6d9f5c9

Now I can use tuples with startswith and endswith.

  • Participants
  • Parent commits df2dddb
  • Branches 4.0

Comments (0)

Files changed (5)

     - generator expressions
     - decorators
     - collections.defaultdict
-    - .startswith((,))
+    + .startswith((,))
 
 
 + Remove code only run on <2.6

File coverage/codeunit.py

         else:
             f = morf
         # .pyc files should always refer to a .py instead.
-        if f.endswith('.pyc') or f.endswith('.pyo'):
+        if f.endswith(('.pyc', '.pyo')):
             f = f[:-1]
         elif f.endswith('$py.class'): # Jython
             f = f[:-9] + ".py"

File coverage/execfile.py

 
     try:
         # Make a code object somehow.
-        if filename.endswith(".pyc") or filename.endswith(".pyo"):
+        if filename.endswith((".pyc", ".pyo")):
             code = make_code_from_pyc(filename)
         else:
             code = make_code_from_py(filename)

File coverage/files.py

     """
     prepped = []
     for p in patterns or []:
-        if p.startswith("*") or p.startswith("?"):
+        if p.startswith(("*", "?")):
             prepped.append(p)
         else:
             prepped.append(abs_file(p))

File tests/test_collector.py

         # duplicates.
         trace_lines = [
             l for l in debug_out.getvalue().splitlines()
-            if l.startswith("Tracing ") or l.startswith("Not tracing ")
+            if l.startswith(("Tracing ", "Not tracing "))
         ]
         filenames = [re.search(r"'[^']+'", l).group() for l in trace_lines]
         self.assertEqual(len(filenames), len(set(filenames)))