Skip to content

Commit

Permalink
check match= message in own depreation warning tests
Browse files Browse the repository at this point in the history
- adapted from 195855c
  • Loading branch information
xflr6 committed May 13, 2024
1 parent 4e0a836 commit 47731a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/backend/test_piping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
with pytest.deprecated_call(match=r'3 positional args'):
out = graphviz.pipe(engine, format_, data,
renderer, formatter).decode('ascii')

Expand Down
2 changes: 1 addition & 1 deletion tests/backend/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
with pytest.deprecated_call(match=r'3 positional args'):
result = graphviz.render(engine, format_, str(lpath),
renderer, formatter)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_all_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
with pytest.deprecated_call(match=r'2 positional args\b'):
assert dot.save(filename, directory) == dot.filepath

assert dot.filename == filename
Expand Down
9 changes: 5 additions & 4 deletions tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,23 @@ def test_filepath(platform, source):


def test_from_file(tmp_path, filename='hello.gv', directory='source_hello',
data='digraph { hello -> world }', encoding='utf-8'):
data='digraph { hello -> world }', encoding='utf-8',
deprecation_match=r'2 positional args\b'):
lpath = tmp_path / directory
lpath.mkdir()
(lpath / filename).write_text(data, encoding=encoding)

with pytest.deprecated_call():
with pytest.deprecated_call(match=deprecation_match):
source = graphviz.Source.from_file(filename, str(lpath))
assert source.encoding == 'utf-8'

with pytest.deprecated_call():
with pytest.deprecated_call(match=deprecation_match):
source = graphviz.Source.from_file(filename, str(lpath), encoding=None)
assert source.encoding == locale.getpreferredencoding()

renderer = 'xdot'
formatter = 'core'
with pytest.deprecated_call():
with pytest.deprecated_call(match=deprecation_match):
source = graphviz.Source.from_file(filename, str(lpath),
encoding=encoding,
renderer=renderer,
Expand Down

0 comments on commit 47731a1

Please sign in to comment.