From 9a8489031d2f9972ffa56bc780a2b93072db0011 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 20 Jun 2022 14:16:13 -0700 Subject: [PATCH] Restore original test_async, test_buffers from current smart_holder HEAD --- tests/test_async.cpp | 50 ----------------------------------------- tests/test_async.py | 14 ------------ tests/test_buffers.cpp | 51 ------------------------------------------ tests/test_buffers.py | 14 ------------ 4 files changed, 129 deletions(-) diff --git a/tests/test_async.cpp b/tests/test_async.cpp index 9de494709..a5d722465 100644 --- a/tests/test_async.cpp +++ b/tests/test_async.cpp @@ -9,52 +9,6 @@ #include "pybind11_tests.h" -#define USE_MRC_AAA -#ifdef USE_MRC_AAA -namespace mrc_ns { // minimal real caster - -template -struct type_mrc { - int value = -9999; -}; - -template -struct minimal_real_caster { - static constexpr auto name = py::detail::const_name(); - static constexpr std::uint64_t universally_unique_identifier = 1000000; - - static py::handle - cast(CType const &src, py::return_value_policy /*policy*/, py::handle /*parent*/) { - return py::int_(src.value + 1010).release(); - } - - // Maximizing simplicity. This will go terribly wrong for other arg types. - template - using cast_op_type = const CType &; - - // NOLINTNEXTLINE(google-explicit-constructor) - operator CType const &() { - static CType obj; - obj.value = 11; - return obj; - } - - bool load(py::handle src, bool /*convert*/) { - // Only accepts str, but the value is ignored. - return py::isinstance(src); - } -}; - -} // namespace mrc_ns - -namespace pybind11 { -namespace detail { -template -struct type_caster> : mrc_ns::minimal_real_caster> {}; -} // namespace detail -} // namespace pybind11 -#endif - TEST_SUBMODULE(async_module, m) { struct DoesNotSupportAsync {}; py::class_(m, "DoesNotSupportAsync").def(py::init<>()); @@ -68,8 +22,4 @@ TEST_SUBMODULE(async_module, m) { f.attr("set_result")(5); return f.attr("__await__")(); }); -#ifdef USE_MRC_AAA - m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc{101}; }); - m.def("type_mrc_from_python", [](const mrc_ns::type_mrc &obj) { return obj.value + 100; }); -#endif } diff --git a/tests/test_async.py b/tests/test_async.py index ca185fa9f..b9ff9514d 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -22,17 +22,3 @@ def test_await(event_loop): def test_await_missing(event_loop): with pytest.raises(TypeError): event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync())) - - -def test_type_mrc_to_python(): - if hasattr(m, "type_mrc_to_python"): - assert m.type_mrc_to_python() == 1111 - else: - pytype.skip("type_mrc_to_python") - - -def test_type_mrc_from_python(): - if hasattr(m, "type_mrc_from_python"): - assert m.type_mrc_from_python("ignored") == 111 - else: - pytype.skip("type_mrc_from_python") diff --git a/tests/test_buffers.cpp b/tests/test_buffers.cpp index 258086003..6b6e8cba7 100644 --- a/tests/test_buffers.cpp +++ b/tests/test_buffers.cpp @@ -12,52 +12,6 @@ #include "constructor_stats.h" #include "pybind11_tests.h" -#define USE_MRC_BBB -#ifdef USE_MRC_BBB -namespace mrc_ns { // minimal real caster - -template -struct type_mrc { - ValType value = -9999; -}; - -template -struct minimal_real_caster { - static constexpr auto name = py::detail::const_name(); - static constexpr std::uint64_t universally_unique_identifier = 2000000; - - static py::handle - cast(CType const &src, py::return_value_policy /*policy*/, py::handle /*parent*/) { - return py::int_(src.value + 2020).release(); - } - - // Maximizing simplicity. This will go terribly wrong for other arg types. - template - using cast_op_type = const CType &; - - // NOLINTNEXTLINE(google-explicit-constructor) - operator CType const &() { - static CType obj; - obj.value = 22; - return obj; - } - - bool load(py::handle src, bool /*convert*/) { - // Only accepts str, but the value is ignored. - return py::isinstance(src); - } -}; - -} // namespace mrc_ns - -namespace pybind11 { -namespace detail { -template -struct type_caster> : mrc_ns::minimal_real_caster> {}; -} // namespace detail -} // namespace pybind11 -#endif - TEST_SUBMODULE(buffers, m) { // test_from_python / test_to_python: class Matrix { @@ -267,9 +221,4 @@ TEST_SUBMODULE(buffers, m) { }); m.def("get_buffer_info", [](const py::buffer &buffer) { return buffer.request(); }); - -#ifdef USE_MRC_BBB - m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc{202}; }); - m.def("type_mrc_from_python", [](const mrc_ns::type_mrc &obj) { return obj.value + 200; }); -#endif } diff --git a/tests/test_buffers.py b/tests/test_buffers.py index 35b97c38e..8354b68cd 100644 --- a/tests/test_buffers.py +++ b/tests/test_buffers.py @@ -161,17 +161,3 @@ def test_ctypes_from_buffer(): assert cinfo.shape == pyinfo.shape assert cinfo.strides == pyinfo.strides assert not cinfo.readonly - - -def test_type_mrc_to_python(): - if hasattr(m, "type_mrc_to_python"): - assert m.type_mrc_to_python() == 2222 - else: - pytype.skip("type_mrc_to_python") - - -def test_type_mrc_from_python(): - if hasattr(m, "type_mrc_from_python"): - assert m.type_mrc_from_python("ignored") == 222 - else: - pytype.skip("type_mrc_from_python")