MCPcopy Create free account
hub / github.com/STIXProject/python-stix / test_deepcopy

Method test_deepcopy

stix/test/core/stix_package_test.py:118–136  ·  view source on GitHub ↗

Test copy.deepcopy() against parsed document. Previous versions of python-stix would cause an exception with copy.deepcopy() when applied to a parsed STIX component which contained timestamp information. This was due to the lack of a __reduce__ function defined on t

(self)

Source from the content-addressed store, hash-verified

116
117 @silence_warnings
118 def test_deepcopy(self):
119 """Test copy.deepcopy() against parsed document.
120
121 Previous versions of python-stix would cause an exception with
122 copy.deepcopy() when applied to a parsed STIX component which contained
123 timestamp information.
124
125 This was due to the lack of a __reduce__ function defined on the
126 bindings._FixedTZOffset class.
127
128 """
129 package = core.STIXPackage.from_xml(
130 BytesIO(
131 core.STIXPackage().to_xml()
132 )
133 )
134
135 copied = copy.deepcopy(package)
136 self.assertEqual(package.timestamp, copied.timestamp)
137
138 @assert_warnings
139 def test_deprecated_idref(self):

Callers

nothing calls this directly

Calls 2

from_xmlMethod · 0.80
to_xmlMethod · 0.45

Tested by

no test coverage detected