From 047569f2003627ddf634e371bca1f4787b5e777e Mon Sep 17 00:00:00 2001 From: Sebastian Bank Date: Mon, 13 May 2024 17:38:26 +0200 Subject: [PATCH] make message `match` more specific --- tests/backend/test_piping.py | 2 +- tests/backend/test_rendering.py | 4 ++-- tests/test_all_classes.py | 2 +- tests/test_sources.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/backend/test_piping.py b/tests/backend/test_piping.py index 3c2f63338e..5a6e658b1c 100644 --- a/tests/backend/test_piping.py +++ b/tests/backend/test_piping.py @@ -75,7 +75,7 @@ def test_pipe_pipe_invalid_data_mocked(mocker, sentinel, mock_run, quiet): reason='https://gitlab.com/graphviz/graphviz/-/issues/1269'))]) def test_pipe(capsys, engine, format_, renderer, formatter, pattern, data=b'graph { spam }'): - with pytest.deprecated_call(match=r'3 positional args'): + with pytest.deprecated_call(match=r'\b3 positional args\b'): out = graphviz.pipe(engine, format_, data, renderer, formatter).decode('ascii') diff --git a/tests/backend/test_rendering.py b/tests/backend/test_rendering.py index ed3531f300..756d0555d3 100644 --- a/tests/backend/test_rendering.py +++ b/tests/backend/test_rendering.py @@ -38,7 +38,7 @@ def test_render_missing_file(quiet, engine='dot', format_='pdf'): ids=lambda x: getattr(x, '__name__', x)) def test_render_unknown_parameter_raises(args, expected_exception, match, supported_number=3): - checker = (pytest.deprecated_call(match=rf'{supported_number:d} positional args') + checker = (pytest.deprecated_call(match=rf'\b{supported_number:d} positional args\b') if len(args) > supported_number else contextlib.nullcontext()) with pytest.raises(expected_exception, match=match), checker: @@ -60,7 +60,7 @@ def test_render(capsys, tmp_path, engine, format_, renderer, formatter, assert lpath.write_bytes(data) == len(data) == lpath.stat().st_size rendered = lpath.with_suffix(f'{lpath.suffix}.{expected_suffix}') - with pytest.deprecated_call(match=r'3 positional args'): + with pytest.deprecated_call(match=r'\b3 positional args\b'): result = graphviz.render(engine, format_, str(lpath), renderer, formatter) diff --git a/tests/test_all_classes.py b/tests/test_all_classes.py index 3c7f46ae17..122bff1c53 100644 --- a/tests/test_all_classes.py +++ b/tests/test_all_classes.py @@ -210,7 +210,7 @@ def test_save_mocked(mocker, dot, filename='nonfilename', directory='nondirector mock_makedirs = mocker.patch('os.makedirs', autospec=True) mock_open = mocker.patch('builtins.open', mocker.mock_open()) - with pytest.deprecated_call(match=r'2 positional args\b'): + with pytest.deprecated_call(match=r'\b2 positional args\b'): assert dot.save(filename, directory) == dot.filepath assert dot.filename == filename diff --git a/tests/test_sources.py b/tests/test_sources.py index c15341798c..5872d0e952 100644 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -43,7 +43,7 @@ def test_filepath(platform, source): def test_from_file(tmp_path, filename='hello.gv', directory='source_hello', data='digraph { hello -> world }', encoding='utf-8', - deprecation_match=r'2 positional args\b'): + deprecation_match=r'\b2 positional args\b'): lpath = tmp_path / directory lpath.mkdir() (lpath / filename).write_text(data, encoding=encoding)