Changed emitted deprecation warnings to a custom DeprecationWarning
subclass. Changed the unit test to test for that specific warning category, instead of any DeprecationWarning.master
parent
27beec4060
commit
5e5a03c001
|
@ -226,3 +226,10 @@ class MarkingNotFoundError(STIXError):
|
|||
def __str__(self):
|
||||
msg = "Marking {0} was not found in {1}!"
|
||||
return msg.format(self.key, self.cls.__class__.__name__)
|
||||
|
||||
|
||||
class STIXDeprecationWarning(DeprecationWarning):
|
||||
"""
|
||||
Represents usage of a deprecated component of a STIX specification.
|
||||
"""
|
||||
pass
|
||||
|
|
|
@ -1378,7 +1378,8 @@ def test_new_version_with_related_objects():
|
|||
|
||||
|
||||
def test_objects_deprecation():
|
||||
with pytest.deprecated_call():
|
||||
with pytest.warns(stix2.exceptions.STIXDeprecationWarning):
|
||||
|
||||
stix2.v21.ObservedData(
|
||||
first_observed="2016-03-12T12:00:00Z",
|
||||
last_observed="2016-03-12T12:00:00Z",
|
||||
|
|
|
@ -8,7 +8,7 @@ from six.moves.urllib.parse import quote_plus
|
|||
|
||||
from ..core import STIXDomainObject
|
||||
from ..custom import _custom_object_builder
|
||||
from ..exceptions import PropertyPresenceError
|
||||
from ..exceptions import PropertyPresenceError, STIXDeprecationWarning
|
||||
from ..properties import (
|
||||
BinaryProperty, BooleanProperty, EmbeddedObjectProperty, EnumProperty,
|
||||
FloatProperty, IDProperty, IntegerProperty, ListProperty,
|
||||
|
@ -578,7 +578,7 @@ class ObservedData(STIXDomainObject):
|
|||
warnings.warn(
|
||||
"The 'objects' property of observed-data is deprecated in "
|
||||
"STIX 2.1.",
|
||||
DeprecationWarning,
|
||||
STIXDeprecationWarning,
|
||||
)
|
||||
|
||||
super(ObservedData, self).__init__(*args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue