File tree 2 files changed +8
-7
lines changed 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,13 @@ TEST_SUBMODULE(class_, m) {
64
64
py::class_<NoConstructor>(m, " NoConstructor" )
65
65
.def_static (" new_instance" , &NoConstructor::new_instance, " Return an instance" )
66
66
.def_classmethod (
67
- " new_instance_uuid " ,
68
- [](py::object &cls) {
69
- py::int_ uuid = getattr (cls, " uuid " , py::int_ (0 ));
70
- cls.attr (" uuid " ) = uuid + py::int_ (1 );
67
+ " new_instance_seq_id " ,
68
+ [](py::type &cls) {
69
+ py::int_ seq_id = getattr (cls, " seq_id " , py::int_ (0 ));
70
+ cls.attr (" seq_id " ) = seq_id + py::int_ (1 );
71
71
return NoConstructorNew::new_instance ();
72
72
},
73
- " Returns a new instance and then increment the uuid " );
73
+ " Returns a new instance and then increment the seq_id " );
74
74
75
75
py::class_<NoConstructorNew>(m, " NoConstructorNew" )
76
76
.def (py::init ([](const NoConstructorNew &self) { return self; })) // Need a NOOP __init__
Original file line number Diff line number Diff line change @@ -32,9 +32,10 @@ def test_instance_new(msg):
32
32
33
33
34
34
def test_classmethod (num_instances = 10 ):
35
+ assert not hasattr (m .NoConstructor , "seq_id" )
35
36
for i in range (num_instances ):
36
- assert getattr ( m .NoConstructor , "uuid" , 0 ) == i
37
- m .NoConstructor .new_instance_uuid ()
37
+ m .NoConstructor . new_instance_seq_id ()
38
+ assert m .NoConstructor .seq_id == i + 1
38
39
39
40
40
41
def test_type ():
You can’t perform that action at this time.
0 commit comments