Modify instances of re.match to fullmatch or search.
This applies the changes to the tests directory only.
This commit is contained in:
parent
b07a4c8c28
commit
9ca6baca4f
@ -74,7 +74,7 @@ def _get_version_tag(tag):
|
||||
(?P<version>\d+\.\d+(\.\d+)?)
|
||||
""", re.VERBOSE)
|
||||
|
||||
match = version_re.match(tag)
|
||||
match = version_re.fullmatch(tag)
|
||||
if not match:
|
||||
return None
|
||||
|
||||
@ -125,7 +125,7 @@ def _get_dictionary_tag(tag):
|
||||
(?P<event>must_have_dict|cannot_have_dict)=(?P<dict>[a-z]{2}-[A-Z]{2})
|
||||
""", re.VERBOSE)
|
||||
|
||||
match = dict_re.match(tag)
|
||||
match = dict_re.fullmatch(tag)
|
||||
if not match:
|
||||
return None
|
||||
|
||||
|
@ -48,7 +48,7 @@ def is_ignored_qt_message(message):
|
||||
"""Check if the message is listed in qt_log_ignore."""
|
||||
regexes = pytest.config.getini('qt_log_ignore')
|
||||
for regex in regexes:
|
||||
if re.match(regex, message):
|
||||
if re.search(regex, message):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -335,7 +335,7 @@ class Process(QObject):
|
||||
if expected is None:
|
||||
return True
|
||||
elif isinstance(expected, regex_type):
|
||||
return expected.match(value)
|
||||
return expected.fullmatch(value)
|
||||
elif isinstance(value, (bytes, str)):
|
||||
return utils.pattern_match(pattern=expected, value=value)
|
||||
else:
|
||||
|
@ -44,7 +44,7 @@ def test_python2():
|
||||
pytest.skip("python2 not found")
|
||||
assert not proc.stdout
|
||||
stderr = proc.stderr.decode('utf-8')
|
||||
assert re.match(TEXT, stderr), stderr
|
||||
assert re.fullmatch(TEXT, stderr), stderr
|
||||
assert proc.returncode == 1
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ def test_patched_no_errwindow(capfd, monkeypatch):
|
||||
checkpyver.check_python_version()
|
||||
stdout, stderr = capfd.readouterr()
|
||||
assert not stdout
|
||||
assert re.match(TEXT, stderr), stderr
|
||||
assert re.fullmatch(TEXT, stderr), stderr
|
||||
|
||||
|
||||
def test_patched_errwindow(capfd, mocker, monkeypatch):
|
||||
|
@ -90,8 +90,8 @@ class TestLogTime:
|
||||
|
||||
assert len(caplog.records) == 1
|
||||
|
||||
pattern = re.compile(r'^Foobar took ([\d.]*) seconds\.$')
|
||||
match = pattern.match(caplog.records[0].msg)
|
||||
pattern = re.compile(r'Foobar took ([\d.]*) seconds\.')
|
||||
match = pattern.fullmatch(caplog.records[0].msg)
|
||||
assert match
|
||||
|
||||
duration = float(match.group(1))
|
||||
|
@ -863,7 +863,7 @@ class TestOpenFile:
|
||||
cmdline = '{} -c pass'.format(executable)
|
||||
utils.open_file('/foo/bar', cmdline)
|
||||
result = caplog.records[0].message
|
||||
assert re.match(
|
||||
assert re.fullmatch(
|
||||
r'Opening /foo/bar with \[.*python.*/foo/bar.*\]', result)
|
||||
|
||||
@pytest.mark.not_frozen
|
||||
@ -872,7 +872,7 @@ class TestOpenFile:
|
||||
cmdline = '{} -c pass {{}} raboof'.format(executable)
|
||||
utils.open_file('/foo/bar', cmdline)
|
||||
result = caplog.records[0].message
|
||||
assert re.match(
|
||||
assert re.fullmatch(
|
||||
r"Opening /foo/bar with \[.*python.*/foo/bar.*'raboof'\]", result)
|
||||
|
||||
@pytest.mark.not_frozen
|
||||
@ -882,7 +882,7 @@ class TestOpenFile:
|
||||
config_stub.val.downloads.open_dispatcher = cmdline
|
||||
utils.open_file('/foo/bar')
|
||||
result = caplog.records[1].message
|
||||
assert re.match(
|
||||
assert re.fullmatch(
|
||||
r"Opening /foo/bar with \[.*python.*/foo/bar.*\]", result)
|
||||
|
||||
def test_system_default_application(self, caplog, config_stub, mocker):
|
||||
@ -890,7 +890,7 @@ class TestOpenFile:
|
||||
new_callable=mocker.Mock)
|
||||
utils.open_file('/foo/bar')
|
||||
result = caplog.records[0].message
|
||||
assert re.match(
|
||||
assert re.fullmatch(
|
||||
r"Opening /foo/bar with the system application", result)
|
||||
m.assert_called_with(QUrl('file:///foo/bar'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user