Skip to content

Commit 75d3a8a

Browse files
committed
Strip out smart_holder code and tests from test_class_sh_shared_ptr_copy_move.
1 parent 7e34433 commit 75d3a8a

File tree

2 files changed

+4
-39
lines changed

2 files changed

+4
-39
lines changed

tests/test_class_sh_shared_ptr_copy_move.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <pybind11/smart_holder.h>
2-
31
#include "pybind11_tests.h"
42

53
#include <memory>
@@ -9,7 +7,7 @@
97
namespace pybind11_tests {
108
namespace {
119

12-
const std::string fooNames[] = {"ShPtr_", "SmHld_"};
10+
const std::string fooNames[] = {"ShPtr_"};
1311

1412
template <int SerNo>
1513
struct Foo {
@@ -29,37 +27,26 @@ struct Foo {
2927
};
3028

3129
using FooShPtr = Foo<0>;
32-
using FooSmHld = Foo<1>;
3330

3431
struct Outer {
3532
std::shared_ptr<FooShPtr> ShPtr;
36-
std::shared_ptr<FooSmHld> SmHld;
37-
Outer()
38-
: ShPtr(std::make_shared<FooShPtr>("Outer")), SmHld(std::make_shared<FooSmHld>("Outer")) {}
33+
Outer() : ShPtr(std::make_shared<FooShPtr>("Outer")) {}
3934
std::shared_ptr<FooShPtr> getShPtr() const { return ShPtr; }
40-
std::shared_ptr<FooSmHld> getSmHld() const { return SmHld; }
4135
};
4236

4337
} // namespace
4438
} // namespace pybind11_tests
4539

46-
PYBIND11_TYPE_CASTER_BASE_HOLDER(pybind11_tests::FooShPtr,
47-
std::shared_ptr<pybind11_tests::FooShPtr>)
48-
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::FooSmHld)
49-
5040
namespace pybind11_tests {
5141

5242
TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
5343
namespace py = pybind11;
5444

5545
py::class_<FooShPtr, std::shared_ptr<FooShPtr>>(m, "FooShPtr")
5646
.def("get_history", &FooShPtr::get_history);
57-
py::classh<FooSmHld>(m, "FooSmHld").def("get_history", &FooSmHld::get_history);
5847

5948
auto outer = py::class_<Outer>(m, "Outer").def(py::init());
60-
#define MAKE_PROP(PropTyp) \
61-
MAKE_PROP_FOO(ShPtr, PropTyp) \
62-
MAKE_PROP_FOO(SmHld, PropTyp)
49+
#define MAKE_PROP(PropTyp) MAKE_PROP_FOO(ShPtr, PropTyp)
6350

6451
#define MAKE_PROP_FOO(FooTyp, PropTyp) \
6552
.def_##PropTyp(#FooTyp "_" #PropTyp "_default", &Outer::FooTyp) \
@@ -88,25 +75,13 @@ TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
8875
l.append(o);
8976
return l;
9077
});
91-
m.def("test_SmHld_copy", []() {
92-
auto o = std::make_shared<FooSmHld>("copy");
93-
auto l = py::list();
94-
l.append(o);
95-
return l;
96-
});
9778

9879
m.def("test_ShPtr_move", []() {
9980
auto o = std::make_shared<FooShPtr>("move");
10081
auto l = py::list();
10182
l.append(std::move(o));
10283
return l;
10384
});
104-
m.def("test_SmHld_move", []() {
105-
auto o = std::make_shared<FooSmHld>("move");
106-
auto l = py::list();
107-
l.append(std::move(o));
108-
return l;
109-
});
11085
}
11186

11287
} // namespace pybind11_tests

tests/test_class_sh_shared_ptr_copy_move.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ def test_shptr_copy():
88
assert txt == "FooShPtr_copy"
99

1010

11-
def test_smhld_copy():
12-
txt = m.test_SmHld_copy()[0].get_history()
13-
assert txt == "FooSmHld_copy"
14-
15-
1611
def test_shptr_move():
1712
txt = m.test_ShPtr_move()[0].get_history()
1813
assert txt == "FooShPtr_move"
1914

2015

21-
def test_smhld_move():
22-
txt = m.test_SmHld_move()[0].get_history()
23-
assert txt == "FooSmHld_move"
24-
25-
2616
def _check_property(foo_typ, prop_typ, policy):
2717
o = m.Outer()
2818
name = f"{foo_typ}_{prop_typ}_{policy}"
@@ -36,6 +26,6 @@ def _check_property(foo_typ, prop_typ, policy):
3626

3727
def test_properties():
3828
for prop_typ in ("readonly", "readwrite", "property_readonly"):
39-
for foo_typ in ("ShPtr", "SmHld"):
29+
for foo_typ in ("ShPtr",):
4030
for policy in ("default", "copy", "move"):
4131
_check_property(foo_typ, prop_typ, policy)

0 commit comments

Comments
 (0)