Skip to content

Commit

Permalink
MAINT: run pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Nov 26, 2024
1 parent a4cf38a commit 62ea149
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions pytest_doctestplus/output_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def __init__(self):
front_sep = r'\s|[*+-,<=(\[]'
back_sep = front_sep + r'|[>j)\]}]'

fbeg = r'^{}(?={}|$)'.format(got_floats, back_sep)
fmidend = r'(?<={}){}(?={}|$)'.format(front_sep, got_floats, back_sep)
self.num_got_rgx = re.compile(r'({}|{})'.format(fbeg, fmidend))
fbeg = fr'^{got_floats}(?={back_sep}|$)'
fmidend = fr'(?<={front_sep}){got_floats}(?={back_sep}|$)'
self.num_got_rgx = re.compile(fr'({fbeg}|{fmidend})')

fbeg = r'^{}(?={}|$)'.format(want_floats, back_sep)
fmidend = r'(?<={}){}(?={}|$)'.format(front_sep, want_floats, back_sep)
self.num_want_rgx = re.compile(r'({}|{})'.format(fbeg, fmidend))
fbeg = fr'^{want_floats}(?={back_sep}|$)'
fmidend = fr'(?<={front_sep}){want_floats}(?={back_sep}|$)'
self.num_want_rgx = re.compile(fr'({fbeg}|{fmidend})')

# As of 2023-09-26, Python base class has no init, but just in case
# it acquires one.
Expand Down Expand Up @@ -220,7 +220,7 @@ def normalize_floats(self, want, got, flags):
# blank line, unless the DONT_ACCEPT_BLANKLINE flag is used.
if not (flags & doctest.DONT_ACCEPT_BLANKLINE):
# Replace <BLANKLINE> in want with a blank line.
want = re.sub(r'(?m)^{}\s*?$'.format(re.escape(doctest.BLANKLINE_MARKER)),
want = re.sub(fr'(?m)^{re.escape(doctest.BLANKLINE_MARKER)}\s*?$',
'', want)
# If a line in got contains only spaces, then remove the
# spaces.
Expand Down
6 changes: 3 additions & 3 deletions pytest_doctestplus/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def write_modified_file(fname, new_fname, changes):
changes.sort(key=lambda x: (x["test_lineno"], x["example_lineno"]),
reverse=True)

with open(fname, "r") as f:
with open(fname) as f:
text = f.readlines()

for change in changes:
Expand Down Expand Up @@ -923,7 +923,7 @@ def write_modified_file(fname, new_fname, changes):
def pytest_terminal_summary(terminalreporter, exitstatus, config):
changesets = DebugRunnerPlus._changesets
diff_mode = DebugRunnerPlus._generate_diff
DebugRunnerPlus._changesets = defaultdict(lambda: [])
DebugRunnerPlus._changesets = defaultdict(list)
DebugRunnerPlus._generate_diff = None
all_bad_tests = []
if not diff_mode:
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):


class DebugRunnerPlus(doctest.DebugRunner):
_changesets = defaultdict(lambda: [])
_changesets = defaultdict(list)
_generate_diff = False

def __init__(self, checker=None, verbose=None, optionflags=0,
Expand Down
4 changes: 2 additions & 2 deletions tests/python/doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def depends_on_two_modules():
"""


class ClassWithSomeBadDocTests(object):
class ClassWithSomeBadDocTests:
def this_test_works():
"""
This test should be executed by --doctest-plus and should pass.
Expand All @@ -98,7 +98,7 @@ def this_test_fails():
"""


class ClassWithAllBadDocTests(object):
class ClassWithAllBadDocTests:
def this_test_fails(self):
"""
This test will cause a failure if __doctest_skip__ is not working.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doctestplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def test_normalize_with_ellipsis(self):
c = OutputChecker()
got = []
for char in ['A', 'B', 'C', 'D', 'E']:
got.append('%s %s' % (char, float(ord(char))))
got.append('{} {}'.format(char, float(ord(char))))
got = '\n'.join(got)

want = "A 65.0\nB 66.0\n...G 70.0"
Expand Down

0 comments on commit 62ea149

Please sign in to comment.