implement __deepcopy__() for ObjectIdentifier (fixes #7587) (#7597)

This commit is contained in:
Mathias Ertl 2022-09-11 18:26:42 +02:00 committed by GitHub
parent 8bc691f580
commit b564cd6725
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -35,6 +35,10 @@ impl ObjectIdentifier {
.getattr(crate::intern!(py, "_OID_NAMES"))?;
oid_names.call_method1("get", (slf, "Unknown OID"))
}
fn __deepcopy__(slf: pyo3::PyRef<'_, Self>, _memo: pyo3::PyObject) -> pyo3::PyRef<'_, Self> {
slf
}
}
#[pyo3::prelude::pyproto]

View file

@ -2,6 +2,7 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
import copy
import pytest
@ -12,6 +13,15 @@ def test_basic_oid():
assert ObjectIdentifier("1.2.3.4").dotted_string == "1.2.3.4"
def test_oid_equal():
assert ObjectIdentifier("1.2.3.4") == ObjectIdentifier("1.2.3.4")
def test_oid_deepcopy():
oid = ObjectIdentifier("1.2.3.4")
assert oid == copy.deepcopy(oid)
def test_oid_constraint():
# Too short
with pytest.raises(ValueError):