diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 768cd072a8..0ccb2c051a 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -64,13 +64,13 @@ TEST_SUBMODULE(class_, m) { py::class_(m, "NoConstructor") .def_static("new_instance", &NoConstructor::new_instance, "Return an instance") .def_classmethod( - "new_instance_uuid", - [](py::object &cls) { - py::int_ uuid = getattr(cls, "uuid", py::int_(0)); - cls.attr("uuid") = uuid + py::int_(1); + "new_instance_seq_id", + [](py::type &cls) { + py::int_ seq_id = getattr(cls, "seq_id", py::int_(0)); + cls.attr("seq_id") = seq_id + py::int_(1); return NoConstructorNew::new_instance(); }, - "Returns a new instance and then increment the uuid"); + "Returns a new instance and then increment the seq_id"); py::class_(m, "NoConstructorNew") .def(py::init([](const NoConstructorNew &self) { return self; })) // Need a NOOP __init__ diff --git a/tests/test_class.py b/tests/test_class.py index e06f92bfe9..dd18f66a0a 100644 --- a/tests/test_class.py +++ b/tests/test_class.py @@ -32,9 +32,10 @@ def test_instance_new(msg): def test_classmethod(num_instances=10): + assert not hasattr(m.NoConstructor, "seq_id") for i in range(num_instances): - assert getattr(m.NoConstructor, "uuid", 0) == i - m.NoConstructor.new_instance_uuid() + m.NoConstructor.new_instance_seq_id() + assert m.NoConstructor.seq_id == i + 1 def test_type():