Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions tests/test_pyfunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,52 +669,52 @@ impl UserDefinedWarning {
#[test]
fn test_pyfunction_warn() {
#[pyfunction]
#[pyo3(warn(message = "this function raises warning"))]
#[pyo3(warn(message = "TPW: this function raises warning"))]
fn function_with_warning() {}

py_expect_warning_for_fn!(
function_with_warning,
f,
[("this function raises warning", PyUserWarning)]
[("TPW: this function raises warning", PyUserWarning)]
);

#[pyfunction]
#[pyo3(warn(message = "this function raises warning with category", category = PyFutureWarning))]
#[pyo3(warn(message = "TPW: this function raises warning with category", category = PyFutureWarning))]
fn function_with_warning_with_category() {}

py_expect_warning_for_fn!(
function_with_warning_with_category,
f,
[(
"this function raises warning with category",
"TPW: this function raises warning with category",
PyFutureWarning
)]
);

#[pyfunction]
#[pyo3(warn(message = "custom deprecated category", category = pyo3::exceptions::PyDeprecationWarning))]
#[pyo3(warn(message = "TPW: custom deprecated category", category = pyo3::exceptions::PyDeprecationWarning))]
fn function_with_warning_with_custom_category() {}

py_expect_warning_for_fn!(
function_with_warning_with_custom_category,
f,
[(
"custom deprecated category",
"TPW: custom deprecated category",
pyo3::exceptions::PyDeprecationWarning
)]
);

#[cfg(not(Py_LIMITED_API))]
#[pyfunction]
#[pyo3(warn(message = "this function raises user-defined warning", category = UserDefinedWarning))]
#[pyo3(warn(message = "TPW: this function raises user-defined warning", category = UserDefinedWarning))]
fn function_with_warning_and_user_defined_category() {}

#[cfg(not(Py_LIMITED_API))]
py_expect_warning_for_fn!(
function_with_warning_and_user_defined_category,
f,
[(
"this function raises user-defined warning",
"TPW: this function raises user-defined warning",
UserDefinedWarning
)]
);
Expand All @@ -723,33 +723,33 @@ fn test_pyfunction_warn() {
#[test]
fn test_pyfunction_multiple_warnings() {
#[pyfunction]
#[pyo3(warn(message = "this function raises warning"))]
#[pyo3(warn(message = "this function raises FutureWarning", category = PyFutureWarning))]
#[pyo3(warn(message = "TPMW: this function raises warning"))]
#[pyo3(warn(message = "TPMW: this function raises FutureWarning", category = PyFutureWarning))]
fn function_with_multiple_warnings() {}

py_expect_warning_for_fn!(
function_with_multiple_warnings,
f,
[
("this function raises warning", PyUserWarning),
("this function raises FutureWarning", PyFutureWarning)
("TPMW: this function raises warning", PyUserWarning),
("TPMW: this function raises FutureWarning", PyFutureWarning)
]
);

#[cfg(not(Py_LIMITED_API))]
#[pyfunction]
#[pyo3(warn(message = "this function raises FutureWarning", category = PyFutureWarning))]
#[pyo3(warn(message = "this function raises user-defined warning", category = UserDefinedWarning))]
#[pyo3(warn(message = "TPMW: this function raises FutureWarning", category = PyFutureWarning))]
#[pyo3(warn(message = "TPMW: this function raises user-defined warning", category = UserDefinedWarning))]
fn function_with_multiple_custom_warnings() {}

#[cfg(not(Py_LIMITED_API))]
py_expect_warning_for_fn!(
function_with_multiple_custom_warnings,
f,
[
("this function raises FutureWarning", PyFutureWarning),
("TPMW: this function raises FutureWarning", PyFutureWarning),
(
"this function raises user-defined warning",
"TPMW: this function raises user-defined warning",
UserDefinedWarning
)
]
Expand Down
Loading