Skip to content

Commit

Permalink
test_native_enum_correct_use_failure -> test_native_enum_missing_fina…
Browse files Browse the repository at this point in the history
…lize_failure
  • Loading branch information
rwgk committed Mar 9, 2025
1 parent c22104f commit 0da489d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions tests/test_native_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,15 @@ TEST_SUBMODULE(native_enum, m) {
});

#if defined(PYBIND11_NEGATE_THIS_CONDITION_FOR_LOCAL_TESTING) && !defined(NDEBUG)
m.def("native_enum_correct_use_failure", []() {
m.def("native_enum_missing_finalize_failure", []() {
enum fake { x };
py::native_enum<fake>(
py::none(), "fake_native_enum_correct_use_failure", py::native_enum_kind::IntEnum)
py::none(), "fake_native_enum_missing_finalize_failure", py::native_enum_kind::IntEnum)
.value("x", fake::x)
.finalize();
// .finalize() missing
;
});
#else
m.attr("native_enum_correct_use_failure") = "For local testing only: terminates process";
m.attr("native_enum_missing_finalize_failure") = "For local testing only: terminates process";
#endif
}
6 changes: 3 additions & 3 deletions tests/test_native_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_double_registration_native_enum_before_enum():
)


def test_native_enum_correct_use_failure():
if not isinstance(m.native_enum_correct_use_failure, str):
m.native_enum_correct_use_failure()
def test_native_enum_missing_finalize_failure():
if not isinstance(m.native_enum_missing_finalize_failure, str):
m.native_enum_missing_finalize_failure()
pytest.fail("Process termination expected.")

0 comments on commit 0da489d

Please sign in to comment.