Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions testflows/_core/cli/arg/handlers/report/srs_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def color_primary():


def result_priority(result):
if result.startswith("X"):
if result[0] == "X":
return 2
elif result == "OK":
return 1
Expand All @@ -45,7 +45,7 @@ def result_priority(result):


def color_result(result):
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=["bold"])
elif result == "OK":
return functools.partial(color, color="green", attrs=["bold"])
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/contrib/markdown2/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def _do_links(self, text):
link_text = text[start_idx+1:p]

# Possibly a footnote ref?
if "footnotes" in self.extras and link_text.startswith("^"):
if "footnotes" in self.extras and link_text[0] == "^":
normed_id = re.sub(r'\W', '-', link_text[1:])
if normed_id in self.footnotes:
self.footnote_ids.append(normed_id)
Expand Down Expand Up @@ -2671,7 +2671,7 @@ def main(argv=None):
try:
for i, line in enumerate(f.readlines()):
if not line.strip(): continue
if line.lstrip().startswith("#"): continue
if line.lstrip()[0] == "#": continue
try:
pat, href = line.rstrip().rsplit(None, 1)
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def __init__(self, **args):

def __call__(self, func):
for k, v in self.items():
if not k.startswith("_"):
if not k[0] == "_":
setattr(func, k, v)
return func

Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/parallel/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def auto_expose(obj):
properties = []

for name, value in inspect.getmembers(obj):
if name.startswith("_"):
if name[0] == "_":
continue

if type(value) in [
Expand Down
8 changes: 4 additions & 4 deletions testflows/_core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ async def _async_cleanup(self):

def __getattr__(self, name):
try:
if name.startswith("_"):
if name[0] == "_":
return self.__dict__[name]
except KeyError:
raise AttributeError(name) from None
Expand All @@ -365,7 +365,7 @@ def __getattr__(self, name):
raise AttributeError(name) from None

def __setattr__(self, name, value):
if name.startswith("_"):
if name[0] == "_":
self.__dict__[name] = value
else:
self._state[name] = value
Expand All @@ -377,7 +377,7 @@ def __delattr__(self, name):
raise AttributeError(name) from None

def __contains__(self, name):
if name.startswith("_"):
if name[0] == "_":
return name in self.__dict__

curr = self
Expand Down Expand Up @@ -2240,7 +2240,7 @@ def __enter__(self, _check_async=True):
),
)
kwargs["args"].update(
{k: v for k, v in cli_args.items() if not k.startswith("_")}
{k: v for k, v in cli_args.items() if k[0] != "_"}
)
if settings.profile:
self.profiler = cProfile.Profile()
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/brisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def color_other(other):
def color_result(result, attrs=None, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def result_icon(result):

if icon is None:
icon = result_icon(result)
if result.startswith("X"):
if result[0] == "X":
return color(icon, "blue", attrs=["bold"])
elif result == "OK":
return color(icon, "green", attrs=["bold"])
Expand Down Expand Up @@ -144,7 +144,7 @@ def format_result(msg):
out += f" {_test}"
if _result_message:
out += f"\n{indent} {color(format_multiline(_result_message, indent).lstrip(), 'yellow', attrs=['bold'])}"
elif result.startswith("X"):
elif result[0] == "X":
out += f" {_test}"
if msg["result_reason"]:
out += f"\n{indent} {color(msg['result_reason'], 'blue', attrs=['bold'])}"
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/dots.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def color_result(result):
if result.startswith("X"):
if result[0] == "X":
return color(".", "blue", attrs=["bold"])
elif result == "OK":
return color(".", "green", attrs=["bold"])
Expand Down
15 changes: 9 additions & 6 deletions testflows/_core/transform/log/fails.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
import textwrap
import functools
import re

import testflows.settings as settings

Expand Down Expand Up @@ -62,7 +63,7 @@ def result_icon(result):

if icon is None:
icon = result_icon(result)
if result.startswith("X"):
if result[0] == "X":
return color(icon, "blue", attrs=["bold"])
elif result == "OK":
return color(icon, "green", attrs=["bold"])
Expand Down Expand Up @@ -207,7 +208,7 @@ def format_result(
if _result_message:
out += f"\n{indent} {color(format_multiline(_result_message, indent).lstrip(), 'yellow', attrs=['bold'])}"
out += "\n"
elif not only_new and result.startswith("X"):
elif not only_new and result[0] == "X":
out += f" {_test}"
if msg["result_reason"]:
out += f"\n{indent} {color(msg['result_reason'], 'blue', attrs=['bold'])}"
Expand Down Expand Up @@ -259,10 +260,12 @@ def transform(
if not test_id in buffer:
buffer[test_id] = []

for _t in skip_for_buffer[0]:
if test_id.startswith(_t + sep):
skip = True
break
pattern = re.compile(
r"|".join(re.escape(_t + sep) for _t in skip_for_buffer[0])
)
if pattern.match(test_id):
skip = True

if not skip:
buffer[test_id].append(line)

Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def color_test_name(name, no_colors=False):
def color_result(result, attrs=None, no_colors=False, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs, no_colors=no_colors)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs, no_colors=no_colors)
Expand Down Expand Up @@ -438,7 +438,7 @@ def format_result(msg, no_colors=False):
if msg["result_message"]:
out += color_test_name(",", no_colors=no_colors)
out += f" {_color(format_multiline(msg['result_message'], _indent).lstrip(), no_colors=no_colors)}"
elif result.startswith("X"):
elif result[0] == "X":
out += f" {_test}"
if msg["result_reason"]:
out += color_test_name(",", no_colors=no_colors)
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def color_test_name(name, no_colors=False):
def color_result(result, attrs=None, no_colors=False, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs, no_colors=no_colors)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs, no_colors=no_colors)
Expand Down Expand Up @@ -470,7 +470,7 @@ def format_result(msg, no_colors=False):
if _result_message:
out += color_test_name(",", no_colors=no_colors)
out += f" {_color(format_multiline(_result_message, _indent).lstrip(), no_colors=no_colors)}"
elif result.startswith("X"):
elif result[0] == "X":
if msg["result_reason"]:
out += color_test_name(",", no_colors=no_colors)
out += f" {_color(msg['result_reason'], no_colors=no_colors)}"
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/nice.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def color_prefix(prefix):
def color_result(result, attrs=None, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/plain.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def color_other(other):
def color_result(result, attrs=None, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/quiet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def color_other(other):
def color_result(result, attrs=None, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand Down Expand Up @@ -100,7 +100,7 @@ def format_result(msg, prefix):

result = msg["result_type"]

if result in ("OK", "Skip") or result.startswith("X"):
if result in ("OK", "Skip") or result[0] == "X":
return

_color = color_result(result)
Expand Down
6 changes: 3 additions & 3 deletions testflows/_core/transform/log/report/fails.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def color_result(result, attrs=None):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand All @@ -49,7 +49,7 @@ def add_result(msg, results):
result = msg["result_type"]

if getattr(TestType, msg["test_type"]) < TestType.Iteration:
if not result.startswith("X"):
if not result[0] == "X":
return
if flags & SKIP and settings.show_skipped is False:
return
Expand Down Expand Up @@ -87,7 +87,7 @@ def generate(results, divider, only_new=False):
)
out += "\n"

if result.startswith("X"):
if result[0] == "X":
if not only_new:
xfails += out
else:
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/report/passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def color_result(result, attrs=None):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs)
Expand Down
2 changes: 1 addition & 1 deletion testflows/_core/transform/log/report/totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def color_line(line):


def color_result(result, text):
if result.startswith("X"):
if result[0] == "X":
return color(text, "blue", attrs=["bold"])
elif result == "OK":
return color(text, "green", attrs=["bold"])
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/short.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def color_test_name(name, no_colors=False, use_full_testname=False):
def color_result(result, attrs=None, no_colors=False, retry=False):
if attrs is None:
attrs = ["bold"]
if result.startswith("X"):
if result[0] == "X":
return functools.partial(color, color="blue", attrs=attrs, no_colors=no_colors)
elif result == "OK":
return functools.partial(color, color="green", attrs=attrs, no_colors=no_colors)
Expand Down Expand Up @@ -463,7 +463,7 @@ def format_result(msg, no_colors=False, use_indent=False, use_full_testname=Fals
if _result_message:
out += color_test_name(",", no_colors=no_colors)
out += f" {_color(format_multiline(_result_message, _indent).lstrip(), no_colors=no_colors)}"
elif result.startswith("X"):
elif result[0] == "X":
out += f" {_test}"
if msg["result_reason"]:
out += color_test_name(",", no_colors=no_colors)
Expand Down
4 changes: 2 additions & 2 deletions testflows/_core/transform/log/slick.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def result_icon(result):
return "\u2718"

icon = result_icon(result)
if result.startswith("X"):
if result[0] == "X":
return color(icon, "blue", attrs=["bold"])
elif result == "OK":
return color(icon, "green", attrs=["bold"])
Expand Down Expand Up @@ -200,7 +200,7 @@ def format_result(msg, last_test_id):
if _result_message:
out += color_test_name(",")
out += f" {color(format_multiline(_result_message, _indent).lstrip(), 'yellow', attrs=['bold'])}"
elif result.startswith("X"):
elif result[0] == "X":
out += f" {_test}"
if msg["result_reason"]:
out += color_test_name(",")
Expand Down
Loading