Skip to content

Commit 2f39da2

Browse files
committed
Capture expected deprecation warnings
Keep conflicting legacy-parameter tests explicit without leaking expected warnings into suite output.
1 parent 08e370a commit 2f39da2

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tests/test_entrypoint.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ def test_write_file_both_parse_stack_and_unparse_stack_raises_error():
143143
temp_path = f.name
144144

145145
try:
146-
with pytest.raises(ValueError) as excinfo:
147-
write_file(temp_path, library, parse_stack=[], unparse_stack=[])
146+
with pytest.warns(DeprecationWarning):
147+
with pytest.raises(ValueError) as excinfo:
148+
write_file(temp_path, library, parse_stack=[], unparse_stack=[])
148149
assert "parse_stack" in str(excinfo.value)
149150
assert "unparse_stack" in str(excinfo.value)
150151
assert "Use 'unparse_stack' instead" in str(excinfo.value)
@@ -160,8 +161,9 @@ def test_write_file_both_append_and_prepend_middleware_raises_error():
160161
temp_path = f.name
161162

162163
try:
163-
with pytest.raises(ValueError) as excinfo:
164-
write_file(temp_path, library, append_middleware=[], prepend_middleware=[])
164+
with pytest.warns(DeprecationWarning):
165+
with pytest.raises(ValueError) as excinfo:
166+
write_file(temp_path, library, append_middleware=[], prepend_middleware=[])
165167
assert "append_middleware" in str(excinfo.value)
166168
assert "prepend_middleware" in str(excinfo.value)
167169
assert "Use 'prepend_middleware' instead" in str(excinfo.value)
@@ -215,8 +217,9 @@ def test_write_string_both_parse_stack_and_unparse_stack_raises_error():
215217
"""Test that providing both parse_stack and unparse_stack raises ValueError."""
216218
library = Library([])
217219

218-
with pytest.raises(ValueError) as excinfo:
219-
write_string(library, parse_stack=[], unparse_stack=[])
220+
with pytest.warns(DeprecationWarning):
221+
with pytest.raises(ValueError) as excinfo:
222+
write_string(library, parse_stack=[], unparse_stack=[])
220223
assert "parse_stack" in str(excinfo.value)
221224
assert "unparse_stack" in str(excinfo.value)
222225
assert "Use 'unparse_stack' instead" in str(excinfo.value)
@@ -226,8 +229,9 @@ def test_write_string_both_append_and_prepend_middleware_raises_error():
226229
"""Test that providing both append_middleware and prepend_middleware raises ValueError."""
227230
library = Library([])
228231

229-
with pytest.raises(ValueError) as excinfo:
230-
write_string(library, append_middleware=[], prepend_middleware=[])
232+
with pytest.warns(DeprecationWarning):
233+
with pytest.raises(ValueError) as excinfo:
234+
write_string(library, append_middleware=[], prepend_middleware=[])
231235
assert "append_middleware" in str(excinfo.value)
232236
assert "prepend_middleware" in str(excinfo.value)
233237
assert "Use 'prepend_middleware' instead" in str(excinfo.value)

0 commit comments

Comments
 (0)